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

How to pass babel transpiling to mocha? #81

Open christian-schwaderer opened 1 year ago

christian-schwaderer commented 1 year ago

I have a mixed JavaScript/TypeScript project. For running, the JavaScript files are getting transpiled via babel-node.

Now, I'm trying to set-up ts-mocha for running tests. However, I keep getting

src/index.js:3

import 'whatever';

^^^^^^

SyntaxError: Cannot use import statement outside a module

I guess, I would need to pass something like --compilers js:@babel/register to mocha. But how do I do that when using ts-mocha?