A TypeScript setup to run and debug Mocha tests without extra configuration and runtime overhead of tools like ts-node.
You can try it out with VS Code or in your browser with Gitpod (requires OAuth with GitHub):
Install typescript and mocha from cli with:
yarn Note: Gitpod auto installs dependencies on the workspace initialization, see .gitpod.yml
Code and tests can be compiled from cli with:
yarn watch Note: Gitpod auto starts watching on each workspace startup, see .gitpod.yml
All tests can be run from cli with:
yarn test An individual ts spec file can be debugged in VS Code or Gitpod with Mocha Tests configuration:
- select a ts spec file, i.e. repo.spec.ts;
- add a breakpoint;
- press
F5to run tests in the selected file.
tsc is configured to compile to lib folder and produce source maps. Mocha Test configuration looks up source maps from the lib folder via outFiles property, and executes tests from all files matching **/${fileBasenameNoExtension}.js, e.g. for src/repo.spec.ts files matching **/repo.spec.js are included.
