Skip to content

Simple TypeScript setup to debug Mocha tests from VS Code

Notifications You must be signed in to change notification settings

akosyakov/ts-mocha-debugging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple TypeScript setup to debug Mocha tests from VS Code

A TypeScript setup to run and debug Mocha tests without extra configuration and runtime overhead of tools like ts-node.

Debugging TypeScript Mocha Tests

You can try it out with VS Code or in your browser with Gitpod (requires OAuth with GitHub):

Open in Gitpod

Installing

Install typescript and mocha from cli with:

yarn

Note: Gitpod auto installs dependencies on the workspace initialization, see .gitpod.yml

Building

Code and tests can be compiled from cli with:

yarn watch

Note: Gitpod auto starts watching on each workspace startup, see .gitpod.yml

Running tests

All tests can be run from cli with:

yarn test

Debugging tests

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 F5 to 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.

About

Simple TypeScript setup to debug Mocha tests from VS Code

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published