|
3 | 3 | * https://jestjs.io/docs/configuration
|
4 | 4 | */
|
5 | 5 |
|
6 |
| -import type { Config } from "jest"; |
| 6 | +// import type { Config } from "jest"; |
| 7 | +import type { JestConfigWithTsJest } from "ts-jest"; |
7 | 8 |
|
8 |
| -const config: Config = { |
| 9 | +const config: JestConfigWithTsJest = { |
9 | 10 | // All imported modules in your tests should be mocked automatically
|
10 | 11 | // automock: false,
|
11 | 12 |
|
@@ -52,6 +53,8 @@ const config: Config = {
|
52 | 53 | // Make calling deprecated APIs throw helpful error messages
|
53 | 54 | // errorOnDeprecated: false,
|
54 | 55 |
|
| 56 | + extensionsToTreatAsEsm: [".ts"], |
| 57 | + |
55 | 58 | // The default configuration for fake timers
|
56 | 59 | // fakeTimers: {
|
57 | 60 | // "enableGlobally": false
|
@@ -90,7 +93,9 @@ const config: Config = {
|
90 | 93 | // ],
|
91 | 94 |
|
92 | 95 | // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
93 |
| - // moduleNameMapper: {}, |
| 96 | + moduleNameMapper: { |
| 97 | + "^(\\.{1,2}/.*)\\.js$": "$1", |
| 98 | + }, |
94 | 99 |
|
95 | 100 | // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
96 | 101 | // modulePathIgnorePatterns: [],
|
@@ -175,7 +180,23 @@ const config: Config = {
|
175 | 180 | // testRunner: "jest-circus/runner",
|
176 | 181 |
|
177 | 182 | // A map from regular expressions to paths to transformers
|
178 |
| - // transform: undefined, |
| 183 | + transform: { |
| 184 | + "^.+\\.tsx?$": [ |
| 185 | + "ts-jest", |
| 186 | + { |
| 187 | + diagnostics: { |
| 188 | + ignoreCodes: [1343], |
| 189 | + }, |
| 190 | + astTransformers: { |
| 191 | + before: [ |
| 192 | + { |
| 193 | + path: "node_modules/ts-jest-mock-import-meta", // or, alternatively, 'ts-jest-mock-import-meta' directly, without node_modules. |
| 194 | + }, |
| 195 | + ], |
| 196 | + }, |
| 197 | + }, |
| 198 | + ], |
| 199 | + }, |
179 | 200 |
|
180 | 201 | // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
181 | 202 | // transformIgnorePatterns: [
|
|
0 commit comments