-
Notifications
You must be signed in to change notification settings - Fork 784
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
Produce clearer, contextual failures when assert.async callbacks are called incorrectly #1595
Conversation
Reverted deletions Essentially renamed/reused only.js
Looking good! 👍 Took a quick peek at the failing Node 10 run: not ok 28 CLI Main > assert.async > drooling calls across tests to assert.async callback
---
message: failed
severity: failed
actual : |+
TAP version 13
not ok 1 Test A
---
message: |+
Died on test #2 at Object.<anonymous> (/qunit/test/cli/fixtures/drooling-done.js:5:7)
- at internal: this is an intentional error
+ at internal
+ at run (/qunit/src/cli/run.js:79:5): this is an intentional error That smells like it might be a combination of Node 10 having slightly different output, and my newly-added normalization logic being imperfect. Might be worth turning that off locally to see what's underneath. I'm hoping there's a straight-forward way to improve the normalization since I'd really not like to go back to pattern matching, but we may have to for a few tests, perhaps as interim solution and then we could try to fix normalize later (or get away with pattern matching until we drop Node 10 late this year, maybe with QUnit 3.0). |
} else { | ||
test( "global failure", extend( function() { | ||
pushFailure( | ||
error.message, | ||
error.stacktrace || error.fileName + ":" + error.lineNumber, | ||
...args | ||
); | ||
}, { validTest: true } ) ); |
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.
I have to self-flag this, after some more thorough bashing. Here's my counter-example:
QUnit.module( "foo", function() {
QUnit.test('hello', assert => {
assert.ok(1);
});
throw new Error("oops");
} );
In the current release, that shows a console error with Uncaught Error: oops
, but it also shows a "global failure" as script error
. In this PR, you see the console error, but otherwise a passing test in the report. That is a no-go, and I will re-work this.
I'm trying to merge #1599 back in, given there's a bunch of overlap, but I'm really wrestling with the churn. |
When the
assert.async
callback is invoked outside of its originating tests, we can issue a better message showing what test it came from. This is true for when it is called in another test (and we leveragepushFailure
) or after all tests have run (and wethrow new Error
).This was done in tandem with removing the global
onError
handler condition where we were outside of tests, instead of making a new "fake" or "placeholder" sort of test on the fly to report those errors, which caused more issues down the line since that was unexpected as far as "hook lifecycles" are concerned.A few prior issues contain some key use cases, which highlight the user-facing differences...
From #1377
Repro:
Current Behavior
CLI
Browser
Same test results, but with errors in console:
Proposed Behavior
CLI
Browser
Same test results, but this is shown in console:
From #1432
Repro:
Current Behavior
CLI
Browser
The second test fails with "script error" and "stack: 0", and with console errors:
Proposed Behavior
CLI
Browser
The test failures are reported the same as above CLI, and the console is empty.