Skip to content

Latest commit

 

History

History
63 lines (39 loc) · 1.39 KB

README.md

File metadata and controls

63 lines (39 loc) · 1.39 KB

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 .\installCmd.sh 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.

Example:

"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)

To get test coverage

npm run coverage

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

"compilerOptions": {
    "types": [
      "mocha"
    ]
}