You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: