piotrwitek / ts-mocha

Mocha thin wrapper that allows running TypeScript tests with TypeScript runtime (ts-node) to get rid of compilation complexity
MIT License
190 stars 25 forks source link

Support mocha 9 #65

Closed aabmass closed 2 years ago

aabmass commented 2 years ago

And any plans to support mocha 9? npm WARN ts-mocha@9.0.0-alpha1 requires a peer of mocha@^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X but none is installed. You must install peer dependencies yourself.

Originally posted by @teolag in https://github.com/piotrwitek/ts-mocha/issues/61#issuecomment-862343195

beenotung commented 2 years ago

My guess is ts-mocha is not affected by the breaking changes introduced in mocha@9.

Can we include || ^9.X.X in the peer dependency list of ts-mocha?

https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#boom-breaking-changes

Pitasi commented 2 years ago

My guess is ts-mocha is not affected by the breaking changes introduced in mocha@9.

Can we include || ^9.X.X in the peer dependency list of ts-mocha?

https://github.com/mochajs/mocha/blob/master/CHANGELOG.md#boom-breaking-changes

mocha@9 became an ESM module. ts-mocha may need some tweaks to make ts-node work with es modules (ESM): https://github.com/TypeStrong/ts-node/issues/1007#issue-598417180

jordaaash commented 2 years ago

FWIW, here's a configuration for Mocha, TypeScript, and ESM that finally worked for me: https://gist.github.com/jordansexton/2a0c3c360aa700cc9528e89620e82c3d

"node-option": ["experimental-specifier-resolution=node", "loader=ts-node/esm"] was the clincher.

juergba commented 2 years ago

mocha@9 became an ESM module.

This is incorrect, Mocha@9 still is a CommonJS module.

piotrwitek commented 2 years ago

Released a new version of ts-mocha@9, please test.