mocha-parallel / mocha-parallel-tests

Parallel test runner for mocha tests. Looking for maintainer.
MIT License
200 stars 45 forks source link

programmatic api vs cli #288

Open lenosky opened 4 years ago

lenosky commented 4 years ago

Hi, I set up typescript test project using ts-node, running .ts tests via cli, using --require ts-mocha, succeeds, but via equal programmatic interface complains with SyntaxError: Cannot use import statement outside a module. Here is a part of it:

require('ts-mocha');

function run() { let specDir = "./specs/"; const mocha = new MochaWrapper(); mocha.timeout(3 * 10000); fs.readdirSync(specDir) .filter(spec => spec.substr(-3) === '.ts') .forEach(spec => mocha.addFile(path.join(specDir, spec))); mocha.run(); }

Target is es6 with commonjs modules.

Please help, how to correctly set it up to run programmatically