Skip to content

arnosolo/template1-express-ts

Repository files navigation

Github

https://github.com/arnosolo/template1-express-ts

Docs

Add jest

  1. Install jest
npm i supertest jest ts-jest @types/jest @types/supertest -D
  1. Add jest.config.js file
npx ts-jest config:init
  1. Rename jest.config.js as jest.config.cjs
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'node',
  testMatch: ['**/**/*.test.ts'], // Test all files end with .test.ts
  verbose: true, // Print log of every test
  forceExit: true, // Always force exit test
};
  1. Add test file src/__tests__/app.test.ts
import request from 'supertest'

describe('give a username and password', () => {
  test('should return true', async () => {
    expect(true).toBe(true)
  })
})
  1. Add test cmd in package.json
"test": "jest"
  1. Run test
npm run test

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors