Closed myocytebd closed 3 months ago
what are you expecting to happen?
the code
does throw, so i'd expect no errors to occur and that's what im seeing when i try this locally
if you can give a little more info, might be able to help
what are you expecting to happen?
the
code
does throw, so i'd expect no errors to occur and that's what im seeing when i try this locallyif you can give a little more info, might be able to help
I got assertion failures with node 18/20/21. (on code
)
.../script.common/node_modules/chai/chai.js:1419
throw new AssertionError(
^
AssertionError: expected [Function] to throw /bbb/ but Error: aaa.bbb was thrown
at evalmachine.<anonymous>:2:13
at Script.runInContext (node:vm:133:12)
at Object.runInContext (node:vm:287:6)
at Immediate.runTest (.../script.common/bbb.js:10:8) {
actual: Error: aaa.bbb
at evalmachine.<anonymous>:2:34
at Proxy.assertThrows (.../script.common/node_modules/chai/chai.js:2668:5)
at Proxy.methodWrapper (.../script.common/node_modules/chai/chai.js:1582:25)
at assert.throws (.../script.common/node_modules/chai/chai.js:3451:71)
at evalmachine.<anonymous>:2:13
at Script.runInContext (node:vm:133:12)
at Object.runInContext (node:vm:287:6)
at Immediate.runTest (.../script.common/bbb.js:10:8),
expected: /bbb/,
showDiff: true,
operator: 'strictEqual'
}
Here it doesn't look correct:
node_modules/chai/chai.js:2668:5 if (errorLike instanceof RegExp || typeof errorLike === "string") {
Built-in globals are per-JSContext and cannot be tested by instanceof.
ah i get you! i was missing the error matcher in my local test
you are correct. we should instead do Object.prototype.toString.call(errorLike) === '[object RegExp]'
@43081j is this fixed now after https://github.com/chaijs/chai/pull/1609?
yup we can close this! 🥳
fixed by #1609
(chai 5.1.0 from npm, node 18.14.0, v8 10.2.154.23-node.22) It seems that assert.throws() does not work correctly in vm spawned context.
Default context assert.throws() work as expected, but vm context assert.throws() asserts where it should pass.