|
1 | | -const ignoreFiles = ['<rootDir>(/.*)*/assets', 'test.utils'] |
| 1 | +/** @type {import('ts-jest').JestConfigWithTsJest} **/ |
| 2 | +const baseConfig = { |
| 3 | + coveragePathIgnorePatterns: ['<rootDir>(/.*)*/assets/'], |
| 4 | + testPathIgnorePatterns: ['<rootDir>(/.*)*/assets', 'test.utils'], |
| 5 | + setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'], |
| 6 | + // Transform all JS and TS files with `ts-jest` |
| 7 | + transform: { |
| 8 | + '^.+.(ts|js)?$': [ |
| 9 | + 'ts-jest', |
| 10 | + { |
| 11 | + // use ESM because we're loading the ESM build of `meilisearch-js` |
| 12 | + useESM: true, |
| 13 | + }, |
| 14 | + ], |
| 15 | + }, |
| 16 | + // Allow `ts-jest` to resolve relative JS imports, e.g., `./folder/index.js` |
| 17 | + // See https://github.com/kulshekhar/ts-jest/issues/1057 |
| 18 | + moduleNameMapper: { |
| 19 | + '(.+)\\.js': '$1', |
| 20 | + }, |
| 21 | + // Treat TS as ESM. JS is automatically treated as ESM |
| 22 | + // if package.json has `"type": "module"` |
| 23 | + extensionsToTreatAsEsm: ['.ts'], |
| 24 | +} |
2 | 25 |
|
3 | | -module.exports = { |
| 26 | +/** @type {import('ts-jest').JestConfigWithTsJest} **/ |
| 27 | +export default { |
4 | 28 | verbose: true, |
5 | 29 | watchPlugins: [ |
6 | 30 | 'jest-watch-typeahead/filename', |
7 | 31 | 'jest-watch-typeahead/testname', |
8 | 32 | ], |
9 | 33 | collectCoverage: true, |
10 | | - setupFilesAfterEnv: ['@testing-library/jest-dom/extend-expect'], |
11 | 34 | projects: [ |
12 | 35 | { |
13 | | - globals: { |
14 | | - 'ts-jest': { tsconfig: 'tsconfig.test.json' }, |
15 | | - fetch: globalThis.fetch, |
16 | | - }, |
17 | | - preset: 'ts-jest', |
| 36 | + ...baseConfig, |
| 37 | + // globals: { |
| 38 | + // 'ts-jest': { tsconfig: 'tsconfig.test.json' }, |
| 39 | + // fetch: globalThis.fetch, |
| 40 | + // }, |
| 41 | + // preset: 'ts-jest', |
18 | 42 | displayName: 'dom', |
19 | | - testPathIgnorePatterns: [...ignoreFiles], |
20 | | - coveragePathIgnorePatterns: ['<rootDir>(/.*)*/assets/'], |
| 43 | + // testPathIgnorePatterns: [...ignoreFiles], |
| 44 | + // coveragePathIgnorePatterns: ['<rootDir>(/.*)*/assets/'], |
21 | 45 | }, |
22 | 46 | { |
23 | | - globals: { |
24 | | - 'ts-jest': { tsconfig: 'tsconfig.test.json' }, |
25 | | - fetch: globalThis.fetch, |
26 | | - }, |
27 | | - preset: 'ts-jest', |
| 47 | + ...baseConfig, |
| 48 | + // globals: { |
| 49 | + // 'ts-jest': { tsconfig: 'tsconfig.test.json' }, |
| 50 | + // fetch: globalThis.fetch, |
| 51 | + // }, |
| 52 | + // preset: 'ts-jest', |
28 | 53 | displayName: 'node', |
29 | 54 | testEnvironment: 'node', |
30 | | - coveragePathIgnorePatterns: ['<rootDir>(/.*)*/assets/'], |
31 | | - testPathIgnorePatterns: [...ignoreFiles], |
| 55 | + // coveragePathIgnorePatterns: ['<rootDir>(/.*)*/assets/'], |
| 56 | + // testPathIgnorePatterns: ['<rootDir>(/.*)*/assets', 'test.utils'], |
32 | 57 | }, |
33 | 58 | ], |
34 | 59 | } |
0 commit comments