Skip to content

dziksu/jest-typescript-introduction

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unit tests using JEST with typescript

Minimal requirements modules to run:

{
  "typescript": "^4.2.4",
  "@types/jest": "^26.0.22",
  "jest": "^26.6.3",
  "ts-jest": "^26.5.5"
}

jest configuration in jest.config.js

module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'node',
};

finally, add some scripts in package.json

{
  "scripts": {
    "test": "jest",
    "test:watch": "jest --watch",
    "test:coverage": "jest --coverage"
  }
}

VSCode Debug

{
  "type": "node",
  "request": "launch",
  "name": "Jest Current File",
  "program": "${workspaceFolder}/node_modules/.bin/jest",
  "args": ["${relativeFile}"],
  "console": "integratedTerminal",
  "internalConsoleOptions": "neverOpen",
  "windows": {
    "program": "${workspaceFolder}/node_modules/jest/bin/jest"
  }
}

Resources

https://medium.com/@RupaniChirag/writing-unit-tests-in-typescript-d4719b8a0a40

https://github.com/ChiragRupani/TSUnitTestsSetup/tree/master/HelloJest

Alternatives

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published