Skip to content

Latest commit

 

History

History
21 lines (19 loc) · 480 Bytes

File metadata and controls

21 lines (19 loc) · 480 Bytes

unit-testing-typescript-nodejs

Practice tests in typescript

Start adding packages

npm i -D typescript ts-node @types/node jest ts-jest @types/jest

Configure Jest to use typescript

// jest.config.js
module.exports = {
  roots: ['<rootDir>/src'],
  transform: {
    '^.+\\.tsx?$': 'ts-jest'
  },
  testRegex: '(/__test__/.*|(\\.|/)(test|spec))\\.[jt]sx?$',
  moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
  verbose: true
}