Skip to content
Starter code to create unit tests in typescript using Jasmine, Mocha/Chai or Jest
Branch: master
Clone or download

Typescript unit tests

This repository contains 3 Projects:

  1. HelloJasmine

  2. HelloMocha

  3. Hello Jest

Each project contains sample source code in src folder and unit tests in tests folder.

The goal is to create starter project using typescript and above testing frameworks along with debugging in VS Code and getting code coverage

Manually Setting up projects

The .\ file contains npm install commands if you want to use same npm package in your existing projects.

The .vscode\launch.json file contains settings for debugging the code in VS Code editor.

The .\Package.json file contains scripts for executing tests.


"scripts": {
    "test": "mocha -r ts-node/register tests/**/*.test.ts"

Also,.\tsconfig.json file is generated using tsc --init command

Test Execution

The tests are executed using

npm t

(which is short for npm run test)

If you get error - describe is not defined, add mocha or jasmine as shown below in ts.config:

"compilerOptions": {
    "types": [
You can’t perform that action at this time.