-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Description
Version
18.17.0
Platform
MacOS
Subsystem
test
What steps will reproduce the bug?
In a test file like:
import { test } from "node:test";
test("failing test", () => {
throw new Error('The failure');
});Run that with node --test and you'll get:
✖ failing test (0.59475ms)
Error: The failure
at TestContext.<anonymous>
Add in chai.should():
import { test } from "node:test";
import chai from 'chai';
chai.should();
test("failing test", () => {
throw new Error('The failure');
});And you instead get:
[Error [ERR_TEST_FAILURE]: The failure] {
[cause]: Error: The failure
at TestContext.<anonymous>
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
All ERR_TEST_FAILURE events given in the data.details.error of a TestStream test:fail should have an err.code and should have that equal 'ERR_TEST_FAILURE', signaling that its err.cause contains the error thrown in the failing test:
| const err = error.code === 'ERR_TEST_FAILURE' ? error.cause : error; |
What do you see instead?
In Node 18.16.1 I saw that, but in Node 18.17.0 adding chai.should() makes it so that no err.code at all appears in the errors in data.details.error in the 'test:fail' TestStream event, yet the stack trace shows that its indeed a ERR_TEST_FAILURE in there somewhere.
This causes checks like these to fail:
| const err = error.code === 'ERR_TEST_FAILURE' ? error.cause : error; |
And eg. causes my diff of Chai errors in @voxpelli/node-test-pretty-reporter to no longer work (unless I do workarounds and check for the presence of the 'ERR_TEST_FAILURE' string in the stack).
Additional information
This is a follow up to #48900 (comment) and is probably caused by the #47867 that @MoLow mentioned in there and which fixed that issue.