chaijs / chai

BDD / TDD assertion framework for node.js and the browser that can be paired with any testing framework.
https://chaijs.github.io
MIT License
8.11k stars 694 forks source link

Chai@4.4.0 syntax error in assertion.js:69 #1573

Closed breandandalton closed 7 months ago

breandandalton commented 8 months ago

Environment: We are currently picking up chai@4.4.0 in our dependency "chai": "^4.1.1". Resolved dependencies: +-- chai@4.4.0 | +-- assertion-error@1.1.0 | +-- check-error@1.0.3 | +-- deep-eql@4.1.3 | +-- get-func-name@2.0.2 | +-- loupe@2.3.7 | +-- pathval@1.1.1 | `-- type-detect@4.0.8

Problem First noticed this problem during a nightly build, at 2024-01-07T00:28:35.648Z (shortly after 4.4.0 was last published) and nightly thereafter:

[2024-01-07T00:28:35.648Z] /srv/mantle-cucumber/node_modules/chai/lib/chai/assertion.js:69 [2024-01-07T00:28:35.648Z] flag(this, 'eql', config.deepEqual ?? util.eql); [2024-01-07T00:28:35.648Z] ^ [2024-01-07T00:28:35.648Z] [2024-01-07T00:28:35.648Z] SyntaxError: Unexpected token ? [2024-01-07T00:28:35.648Z] at createScript (vm.js:56:10) [2024-01-07T00:28:35.648Z] at Object.runInThisContext (vm.js:97:10) [2024-01-07T00:28:35.648Z] at Module._compile (module.js:549:28) [2024-01-07T00:28:35.648Z] at Object.Module._extensions..js (module.js:586:10) [2024-01-07T00:28:35.648Z] at Module.load (module.js:494:32) [2024-01-07T00:28:35.648Z] at tryModuleLoad (module.js:453:12) [2024-01-07T00:28:35.648Z] at Function.Module._load (module.js:445:3) [2024-01-07T00:28:35.648Z] at Module.require (module.js:504:17) [2024-01-07T00:28:35.648Z] at require (internal/module.js:20:19) [2024-01-07T00:28:35.648Z] at Object. (/srv/mantle-cucumber/node_modules/chai/lib/chai.js:63:17)

Reverting to version 4.3.10 resolved the issue.

43081j commented 7 months ago

seems this is because a PR introduced ?? syntax which breaks node compatibility

what version of node do you use?

you can prove that's the case by using a newer node version temporarily and seeing if the error stops happening.

if that is the case, we may need to revert the syntax

koddsson commented 7 months ago

Fixed in 4.4.1.