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

TypeError: Unknown file extension ".ts" with Chai 5.0.0 and later #1607

Closed npapagna closed 6 months ago

npapagna commented 6 months ago

I get TypeError: Unknown file extension ".ts" when trying to run mocha tests using ts-node with chai 5.0.0 and later. Downgrading it to 4.4.1 seems to fix the issue.

Check this repo with a minimal example that reproduces the bug

43081j commented 6 months ago

this is because chai 5.x is esm-only

if you're in a commonjs project, you should stick to 4.x (which we are still supporting) or migrate to ESM (add type: "module" to your package.json).

you can see an example of an esm project working with ts-node and mocha here: https://gist.github.com/43081j/78ce1392abb5043b02a29355006880a5/

npapagna commented 6 months ago

Thanks, it worked great!