From d63005e61a106ad7a9240ddf3b782fa46af675df Mon Sep 17 00:00:00 2001 From: Iacami Gevaerd Date: Tue, 14 Nov 2023 10:13:58 -0300 Subject: [PATCH] chore: make jest tests work in src (not build) files --- jest.config.cjs | 15 +++++++++++++-- package.json | 2 +- tsconfig.json | 3 +-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/jest.config.cjs b/jest.config.cjs index ea6b6706..18bb8139 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -1,7 +1,18 @@ module.exports = { - preset: 'ts-jest', + moduleNameMapper: { + '^(\\.{1,2}/.*)\\.js$': '$1' + }, + extensionsToTreatAsEsm: ['.ts'], + transform: { + '^.+\\.(mt|t|cj|j)s$': [ + 'ts-jest', + { + useESM: true + } + ] + }, testEnvironment: 'node', testMatch: [ - '/build/**/__tests__/*.js' + '/**/__tests__/*.ts' ] } diff --git a/package.json b/package.json index fbbfcbde..a83b795f 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "scripts": { "lint": "yarn ts-standard", "fix": "yarn ts-standard --fix", - "test": "yarn build && cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --runInBand", + "test": "cross-env NODE_OPTIONS=\"--experimental-vm-modules\" jest --runInBand", "build": "tsc -p tsconfig.json", "build-release": "tsc -p tsconfig.release.json", "clean": "tsc -b --clean && rm -rf build/*", diff --git a/tsconfig.json b/tsconfig.json index 871ed609..3b503295 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,7 +10,6 @@ "module": "ESNext", "esModuleInterop": true, "moduleResolution": "Node", - "rootDir": "./src", "outDir": "build", "sourceMap": true, "strictNullChecks": true, @@ -21,4 +20,4 @@ "include": [ "src/**/*.ts", ] -} \ No newline at end of file +}