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

TypeScript support #199

Open
MagicLegend opened this issue Mar 18, 2020 · 0 comments
Open

TypeScript support #199

MagicLegend opened this issue Mar 18, 2020 · 0 comments

Comments

@MagicLegend
Copy link

MagicLegend commented Mar 18, 2020

This is more for documentation, and I think could be included in the readme of this plugin for other people.

Based on the information found here (archived), I figured out that the transpilation of ts to js is not neccisary when using this plugin. By passing the require argument to mocha, one can directly pass it ts. It would look as follows in your gulpfile.js:

const gulp = require('gulp');
const mocha = require('gulp-mocha');

gulp.task('mocha', () => {
    return gulp.src('test/**/*.test.ts').pipe(mocha({ require: 'ts-node/register', reporter: 'nyan' }));
});

Obviously this also requires the ts-node npm package.

This saves a transpilation step, and how to use the VSCode debugger directly on the ts files is described in the mentioned article (also handy trick!). I hope this helps someone :-)

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