-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
chai.should()
breaks error serialization
#48918
Comments
can you alaborate more? const chai = require("chai");
chai.should(); also - in your example you call this outside of a test - is that intended? |
@MoLow The mere act of This is the minimal reproduction of the issue I saw here but you couldn’t reproduce: #48900 (comment) After narrowing it down I realized that the mere activation of the “should”-style of Chai caused it (the one that enables one to write |
This appears to be related to Node's error serialization, and not specific to the test runner. It might be related to 78972d4696, which is new in 18.17.0, but I have not bisected. The bug shows up with
Here is a more minimal repro (note you must start Node with 'use strict';
const {
deserializeError,
serializeError
} = require('internal/error_serdes');
// Comment out the following line to see the difference.
Object.prototype.boom = new Proxy({}, {});
const err = new Error('message');
err.code = 123;
const serialized = serializeError(err);
const deserialized = deserializeError(serialized);
console.log(deserialized.code); I would say that chai should not be doing what it's doing, but Node could also handle it better. |
18.17.0
test runner gives reporters no error metadata with chai.should()
chai.should()
breaks error serialization
Version
18.17.0
Platform
MacOS
Subsystem
test
What steps will reproduce the bug?
In a test file like:
Run that with
node --test
and you'll get:Add in
chai.should()
:And you instead get:
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 thedata.details.error
of aTestStream
test:fail
should have anerr.code
and should have that equal'ERR_TEST_FAILURE'
, signaling that itserr.cause
contains the error thrown in the failing test:node/lib/internal/test_runner/reporter/spec.js
Line 59 in 36c72c8
What do you see instead?
In Node
18.16.1
I saw that, but in Node18.17.0
addingchai.should()
makes it so that noerr.code
at all appears in the errors indata.details.error
in the'test:fail'
TestStream
event, yet the stack trace shows that its indeed aERR_TEST_FAILURE
in there somewhere.This causes checks like these to fail:
node/lib/internal/test_runner/reporter/spec.js
Line 59 in 36c72c8
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.
The text was updated successfully, but these errors were encountered: