-
npm install mocha chai ts-node typescript @types/mocha @types/chai --save-dev
-
Edit your
package.json
to include:scripts: { "test": "node --harmony node_modules/mocha/bin/mocha --harmony -r ts-node/register *.spec.ts" }
I also use
--harmony
since my code makes use ofSymbol.asyncIterable
.
Beware that even though this builds TypeScript files your specs depend on for the first time, it does not rebuild them upon changes. My workflow is to havetsc -w
running in the background and continuously runnpm test
. -
Write them, see
sample.spec.ts
.
npm install chai-as-promised @types/chai-as-promised --save-dev
- Write them, see
sample-async.spec.ts
.