Add Jest to support backend unit tests
This commit is contained in:
parent
d46e1abd07
commit
352f0817d9
17
backend/jest.config.ts
Normal file
17
backend/jest.config.ts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import type { Config } from "@jest/types"
|
||||||
|
|
||||||
|
const config: Config.InitialOptions = {
|
||||||
|
preset: "ts-jest",
|
||||||
|
testEnvironment: "node",
|
||||||
|
verbose: true,
|
||||||
|
automock: false,
|
||||||
|
collectCoverage: true,
|
||||||
|
collectCoverageFrom: ["./src/**/**.ts"],
|
||||||
|
coverageProvider: "v8",
|
||||||
|
coverageThreshold: {
|
||||||
|
global: {
|
||||||
|
lines: 90
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default config;
|
5995
backend/package-lock.json
generated
5995
backend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -20,11 +20,11 @@
|
|||||||
],
|
],
|
||||||
"main": "index.ts",
|
"main": "index.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"tsc": "./node_modules/typescript/bin/tsc",
|
"tsc": "./node_modules/typescript/bin/tsc -p tsconfig.build.json",
|
||||||
"build": "npm run tsc",
|
"build": "npm run tsc",
|
||||||
"start": "node --max-old-space-size=2048 dist/index.js",
|
"start": "node --max-old-space-size=2048 dist/index.js",
|
||||||
"start-production": "node --max-old-space-size=4096 dist/index.js",
|
"start-production": "node --max-old-space-size=4096 dist/index.js",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "./node_modules/.bin/jest --coverage",
|
||||||
"lint": "./node_modules/.bin/eslint . --ext .ts",
|
"lint": "./node_modules/.bin/eslint . --ext .ts",
|
||||||
"lint:fix": "./node_modules/.bin/eslint . --ext .ts --fix",
|
"lint:fix": "./node_modules/.bin/eslint . --ext .ts --fix",
|
||||||
"prettier": "./node_modules/.bin/prettier --write \"src/**/*.{js,ts}\""
|
"prettier": "./node_modules/.bin/prettier --write \"src/**/*.{js,ts}\""
|
||||||
@ -46,11 +46,15 @@
|
|||||||
"@types/compression": "^1.7.2",
|
"@types/compression": "^1.7.2",
|
||||||
"@types/crypto-js": "^4.1.1",
|
"@types/crypto-js": "^4.1.1",
|
||||||
"@types/express": "^4.17.13",
|
"@types/express": "^4.17.13",
|
||||||
|
"@types/jest": "^28.1.4",
|
||||||
"@types/ws": "~8.5.3",
|
"@types/ws": "~8.5.3",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.30.5",
|
"@typescript-eslint/eslint-plugin": "^5.30.5",
|
||||||
"@typescript-eslint/parser": "^5.30.5",
|
"@typescript-eslint/parser": "^5.30.5",
|
||||||
"eslint": "^8.19.0",
|
"eslint": "^8.19.0",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.5.0",
|
||||||
"prettier": "^2.7.1"
|
"jest": "^28.1.2",
|
||||||
|
"prettier": "^2.7.1",
|
||||||
|
"ts-jest": "^28.0.5",
|
||||||
|
"ts-node": "^10.8.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
"types": ["node"],
|
"types": ["node"],
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"target": "esnext",
|
"target": "esnext",
|
||||||
|
"types": ["node", "jest"],
|
||||||
"lib": ["es2019", "dom"],
|
"lib": ["es2019", "dom"],
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"noImplicitAny": false,
|
"noImplicitAny": false,
|
||||||
@ -21,4 +22,4 @@
|
|||||||
"exclude": [
|
"exclude": [
|
||||||
"dist/**"
|
"dist/**"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user