mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-11-08 05:03:39 +08:00
Add typescript support for jest (#3949) rizwanmustafa
* Add typescript support for jest * Add typescript support for jest setup-tests.ts * Some more bug fixing
This commit is contained in:
parent
6c9ee41444
commit
85f52ff49e
3 changed files with 26 additions and 3 deletions
|
|
@ -2,14 +2,14 @@ import { Collection, Db, MongoClient, WithId } from "mongodb";
|
|||
|
||||
process.env.MODE = "dev";
|
||||
|
||||
jest.mock("./src/init/db", () => ({
|
||||
jest.mock("../src/init/db", () => ({
|
||||
__esModule: true,
|
||||
getDb: (): Db => db,
|
||||
collection: <T>(name: string): Collection<WithId<T>> =>
|
||||
db.collection<WithId<T>>(name),
|
||||
}));
|
||||
|
||||
jest.mock("./src/utils/logger", () => ({
|
||||
jest.mock("../src/utils/logger", () => ({
|
||||
__esModule: true,
|
||||
default: {
|
||||
error: console.error,
|
||||
22
backend/__tests__/tsconfig.json
Normal file
22
backend/__tests__/tsconfig.json
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"incremental": true,
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"sourceMap": false,
|
||||
"allowJs": true,
|
||||
"checkJs": true,
|
||||
"outDir": "build",
|
||||
"moduleResolution": "node",
|
||||
"resolveJsonModule": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"strictNullChecks": true,
|
||||
"skipLibCheck": true,
|
||||
"noEmit": true
|
||||
},
|
||||
"ts-node": {
|
||||
"files": true
|
||||
},
|
||||
"include": ["./**/*.spec.ts", "./setup-tests.ts"]
|
||||
}
|
||||
|
|
@ -3,7 +3,8 @@ import { defaults as tsjPreset } from "ts-jest/presets";
|
|||
export default {
|
||||
preset: "@shelf/jest-mongodb",
|
||||
transform: tsjPreset.transform,
|
||||
setupFilesAfterEnv: ["<rootDir>/setup-tests.ts"],
|
||||
setupFilesAfterEnv: ["<rootDir>/__tests__/setup-tests.ts"],
|
||||
modulePathIgnorePatterns: ["<rootDir>/__tests__/setup-tests.ts"],
|
||||
coverageThreshold: {
|
||||
global: {
|
||||
// These percentages should never decrease
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue