|
1 |
| -// For a detailed explanation regarding each configuration property, visit: |
2 |
| -// https://jestjs.io/docs/en/configuration.html |
| 1 | +/* eslint-disable */ |
| 2 | +const { readFileSync } = require('fs'); |
| 3 | + |
| 4 | +// Reading the SWC compilation config and remove the "exclude" |
| 5 | +// for the test files to be compiled by SWC |
| 6 | +const { exclude: _, ...swcJestConfig } = JSON.parse( |
| 7 | + readFileSync(`${__dirname}/.swcrc`, 'utf-8'), |
| 8 | +); |
| 9 | + |
| 10 | +// disable .swcrc look-up by SWC core because we're passing in swcJestConfig ourselves. |
| 11 | +// If we do not disable this, SWC Core will read .swcrc and won't transform our test files due to "exclude" |
| 12 | +swcJestConfig.swcrc ??= false; |
| 13 | +// Uncomment if using global setup/teardown files being transformed via swc |
| 14 | +// https://nx.dev/packages/jest/documents/overview#global-setup/teardown-with-nx-libraries |
| 15 | +// jest needs EsModule Interop to find the default exported setup/teardown functions |
| 16 | +// swcJestConfig.module.noInterop = false; |
3 | 17 |
|
4 | 18 | module.exports = {
|
5 | 19 | clearMocks: true,
|
| 20 | + cache: false, |
6 | 21 | testEnvironment: 'jsdom',
|
7 | 22 | coveragePathIgnorePatterns: ['__tests__', '/node_modules/'],
|
8 |
| - coverageProvider: 'v8', |
9 |
| - coverageReporters: ['cobertura', 'clover', 'json', 'lcov', 'text'], |
10 | 23 | globals: {
|
11 | 24 | __DEV__: true,
|
12 | 25 | __TEST__: true,
|
13 | 26 | __BROWSER__: false,
|
14 |
| - __VERSION__: '"unknow"', |
| 27 | + __VERSION__: '"unknown"', |
15 | 28 | },
|
16 | 29 | preset: 'ts-jest',
|
17 | 30 | transformIgnorePatterns: [
|
18 | 31 | // Change MODULE_NAME_HERE to your module that isn't being compiled
|
19 | 32 | '/node_modules/(?!((@byted/garfish-)|(byted-tea-sdk))).+\\.js$',
|
20 | 33 | ],
|
21 | 34 | transform: {
|
22 |
| - '^.+\\.(t|j)sx?$': ['@swc/jest'], |
| 35 | + '^.+\\.(t|j)sx?$': ['@swc/jest', swcJestConfig], |
23 | 36 | },
|
24 | 37 | rootDir: __dirname,
|
25 | 38 | testMatch: ['<rootDir>__tests__/**/**.spec.[jt]s?(x)'],
|
|
0 commit comments