Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

programmatic api vs cli #288

Open
lenosky opened this issue Apr 24, 2020 · 0 comments
Open

programmatic api vs cli #288

lenosky opened this issue Apr 24, 2020 · 0 comments

Comments

@lenosky
Copy link

lenosky commented Apr 24, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant