|
| 1 | +// these paths must be specified because otherwise typescript relies on the |
| 2 | +// "main" field in each package.json file, which points to the compiled JS and |
| 3 | +// we want to run Jest against the TS source |
| 4 | +const paths = { |
| 5 | + // @bugsnag/core must resolve to source so that module-level singleton state |
| 6 | + // (e.g. clone-client's onCloneCallbacks) is shared across jest.isolateModules |
| 7 | + // boundaries. Without this, bundled dist creates duplicate state. |
| 8 | + '@bugsnag/core': ['./packages/core/src/index.ts'] |
| 9 | +} |
| 10 | + |
| 11 | +const moduleNameMapper = Object.fromEntries( |
| 12 | + Object.entries(paths) |
| 13 | + .map(([name, directories]) => [ |
| 14 | + `^${name}$`, |
| 15 | + directories.map(directory => directory.replace('./', '<rootDir>/')) |
| 16 | + ]) |
| 17 | +) |
| 18 | + |
| 19 | +const defaultModuleConfig = { |
| 20 | + preset: 'ts-jest/presets/js-with-ts', |
| 21 | + moduleNameMapper, |
| 22 | + transform: { |
| 23 | + '^.+\\.m?[tj]sx?$': [ |
| 24 | + 'ts-jest', |
| 25 | + { |
| 26 | + isolatedModules: true, |
| 27 | + tsconfig: { |
| 28 | + module: 'commonjs', |
| 29 | + target: 'ES2019', |
| 30 | + esModuleInterop: true, |
| 31 | + allowSyntheticDefaultImports: true, |
| 32 | + allowJs: true, |
| 33 | + skipLibCheck: true, |
| 34 | + jsx: 'react', |
| 35 | + paths |
| 36 | + } |
| 37 | + } |
| 38 | + ] |
| 39 | + } |
| 40 | +} |
| 41 | + |
1 | 42 | module.exports = { |
2 | 43 | projects: [ |
3 | 44 | { |
4 | | - resolver: '<rootDir>/jest/node-exports-resolver', |
| 45 | + ...defaultModuleConfig, |
5 | 46 | setupFilesAfterEnv: ['<rootDir>/test/electron/setup.ts'], |
6 | 47 | clearMocks: true, |
7 | 48 | modulePathIgnorePatterns: ['.verdaccio', 'fixtures', 'examples'], |
8 | 49 | displayName: 'electron main', |
9 | | - runner: '@jest-runner/electron/main', |
| 50 | + runner: '@kayahr/jest-electron-runner/main', |
| 51 | + testEnvironment: 'node', |
10 | 52 | testMatch: ['**/test/**/*.test-main.ts'] |
11 | 53 | }, |
12 | 54 | { |
13 | | - resolver: '<rootDir>/jest/node-exports-resolver', |
| 55 | + ...defaultModuleConfig, |
14 | 56 | setupFilesAfterEnv: ['<rootDir>/test/electron/setup.ts'], |
15 | 57 | clearMocks: true, |
16 | 58 | modulePathIgnorePatterns: ['.verdaccio', 'fixtures', 'examples'], |
17 | 59 | displayName: 'electron renderer', |
18 | | - runner: '@jest-runner/electron', |
| 60 | + runner: '@kayahr/jest-electron-runner', |
| 61 | + testEnvironment: '@kayahr/jest-electron-runner/environment', |
19 | 62 | testMatch: ['**/test/**/*.test-renderer.ts'] |
20 | 63 | } |
21 | 64 | ] |
|
0 commit comments