-
-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Report skipped assertions #486
base: master
Are you sure you want to change the base?
Report skipped assertions #486
Conversation
@ljharb, I've implemented what was discussed previously, as-is, but I think the output is confusing. For example:
Now becomes:
And the numbers don't add-up: when a test suite is marked as skipped, all assertions inside are ignored and not counted. Maybe we need to add a count of test suites separate from the count of assertions that we have now. |
hmm, i'm confused. if they're not counted, they shouldn't show up in "tests" either, no? |
Correct. The count of skip is a number mixing skipped assertions and skipped tests, and can't be reconciled in a formula Showing
|
Is the issue that the "tests" doesn't include the "skips"? iow, |
Correct. It's a simple thing, but we should avoid confusion. That's why I'm on the fence with this one. |
so to restate:
It seems to me that the proper fix is to include skips in tests - since the total number of tests in the above example is actually 869 anyways - iow, it's a bug that they're not counted. Thoughts? |
Correct, that's the idea, but it's not possible. Here, by following the direction of the original PR, I realized the discrepancy: Skip is usually done at the test level and count at the assertion level Compare: test("foo", t => {
t.pass();
t.pass();
});
With: test("foo", t => {
t.pass();
t.pass();
});
Skip can be counted at the two levels:
I think we need two different counts:
Which would result in an output similar to Jest, with a distinction between test suites and tests:
And that's where I think we would interfere with the TAP protocol. |
Hmm, that seems to suggest that this PR isn't really an option unless a skipped test still evaluates, but all the tests i skip are because they will not successfully evaluate. |
Adding the |
That doesn’t seem like the right concept to me; a file isn’t automatically 1 suite, it might be N |
I agree, a file isn't a single suite. As far as I can find neither does TAP describe any "suites" or diagnostic output lines like tape does. It's simply subjective taste and I think what this PR is trying to do falls under this category. TAP consumers just ignore the comment lines anyway. |
A "test suite" corresponds to a "describe()" test group in Jest, and it's not counting files. Jestdescribe('my beverage', () => {
test('is delicious', () => {
expect(myBeverage.delicious).toBeTruthy();
});
test('is not sour', () => {
expect(myBeverage.sour).toBeFalsy();
});
});
TapeMy suggestion would be to count "test()" groups in Tape. test('my beverage', t => {
t.test('is delicious', tt => {
tt.ok(myBeverage.delicious);
});
t.test('is not sour', tt => {
tt.notOk(myBeverage.sour);
});
});
|
That might map well in many cases, altho i often - in both jest and tape - have a single top level describe/test, with everything nested underneath - so that pattern wouldn’t really mesh well for my use cases. |
@@ -104,6 +105,7 @@ Results.prototype._watch = function (t) { | |||
var write = function (s) { self._stream.queue(s); }; | |||
t.once('prerun', function () { | |||
var premsg = ''; | |||
if (t._skip) self.skip ++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is just an update to an old PR meant to illustrate the problem you are mentioning: tests and assertions are mixed together.
The reason the two are mixed together is that tape
reports "assertions" as "tests", and doesn't count suites.
# tests 2
# pass 1
# fail 1
If we don't count suites, the only way to indicate that some assertions are skipped is to add one to tests because we don't know how many are actually skipped. That create the problem that you are mentioning.
The solution is probably to change the count and the output to be something like node-tap
:
Suites: 1 failed, 1 passed, 1 skipped, 3 of 3 completed
Asserts: 2 failed, 3 passed, 2 skipped, of 7
My concern is not to break people with this change, so I will probably do this behind a flag. Once we agree on the output and the necessity of a flag, then the changes will be trivial.
What's your take? If would be great if you could help me by testing the upcoming changes in your environment. :)
I'm preparing to release v5, but I'm not yet confident about the design of this feature to include it in v5, so I think it'll have to wait for v6. |
c16dde3
to
2ad86d4
Compare
test.skip(fn, cb)
would behave differently fromtest(fn, { skip: true }, cb)
and not mark the tests with prefix# SKIP
This is a rebase and simplification of PR #197
References:
Issue #90
Issue #115