Skip to content

Instantly share code, notes, and snippets.

@Hiweus
Created March 11, 2022 13:28
Show Gist options
  • Save Hiweus/76b1e5285c4221822b277371d67121c4 to your computer and use it in GitHub Desktop.
Save Hiweus/76b1e5285c4221822b277371d67121c4 to your computer and use it in GitHub Desktop.

Configure mocha to watch typescript files

When you use mocha with flag --watch on typescript you need to set .mocharc.json file on root folder of project to specify for mocha watch .ts files; Otherwise the terminal will spawn in the first run but will not restart when you save the file.

// .mocharc.json
{
    "extension": [
        "ts"
    ],
    "spec": "__tests__/**/*.spec.ts",
    "watch": true
}
# Simple run on terminal
yarn ts-mocha
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment