TSUnitTestsSetup
Starter code to create unit tests in typescript using Jasmine, Mocha/Chai, Jest or Vitest
Install / Use
/learn @ChiragRupani/TSUnitTestsSetupREADME
Typescript unit tests
This repository contains 4 Projects:
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
<hr/>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
<hr/>
If you get error - describe is not defined, add mocha or jasmine as shown below in ts.config:
"compilerOptions": {
"types": [
"mocha"
]
}
