mocha-parallel-tests icon indicating copy to clipboard operation
mocha-parallel-tests copied to clipboard

programmatic api vs cli

Open lenosky opened this issue 4 years ago • 0 comments

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

lenosky avatar Apr 24 '20 19:04 lenosky