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
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