|
1 |
| -const nextJest = require('next/jest') |
| 1 | +const nextJest = require('next/jest'); |
2 | 2 |
|
3 | 3 | // Providing the path to your Next.js app which will enable loading next.config.js and .env files
|
4 |
| -const createJestConfig = nextJest({ dir: './' }) |
| 4 | +const createJestConfig = nextJest({ dir: './' }); |
5 | 5 |
|
6 | 6 | const customJestConfig = {
|
7 | 7 | rootDir: './',
|
8 |
| - setupFilesAfterEnv: ["<rootDir>/.jest/setup.ts"], |
9 | 8 | moduleDirectories: ["node_modules", "<rootDir>/"],
|
| 9 | + setupFilesAfterEnv: ["<rootDir>/.jest/setup.ts"], |
10 | 10 | moduleFileExtensions: ['js', 'ts', 'tsx', 'json'],
|
11 |
| - testPathIgnorePatterns: ['<rootDir>[/\\\\](node_modules|.next)[/\\\\]'], |
12 |
| - transformIgnorePatterns: ['[/\\\\]node_modules[/\\\\].+\\.(ts|tsx)$'], |
| 11 | + testMatch: [ |
| 12 | + "**/__tests__/**/*.+(ts|tsx|js)", |
| 13 | + "**/?(*.)+(spec|test).+(ts|tsx|js)" |
| 14 | + ], |
| 15 | + testPathIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/.next/'], |
| 16 | + testEnvironment: 'jest-environment-jsdom', |
13 | 17 | moduleNameMapper: {
|
14 | 18 | '\\.(css|less|sass|scss)$': 'identity-obj-proxy',
|
15 | 19 | '\\.(gif|ttf|eot|svg|png)$': '<rootDir>/__test__/__mocks__/fileMock.js',
|
@@ -41,4 +45,17 @@ const customJestConfig = {
|
41 | 45 | },
|
42 | 46 | };
|
43 | 47 |
|
44 |
| -module.exports = createJestConfig(customJestConfig); |
| 48 | +module.exports = async () => ({ |
| 49 | + /** |
| 50 | + * Using ...(await createJestConfig(customJestConfig)()) to override transformIgnorePatterns |
| 51 | + * provided byt next/jest. |
| 52 | + * |
| 53 | + * @link https://github.com/vercel/next.js/issues/36077#issuecomment-1096635363 |
| 54 | + */ |
| 55 | + ...(await createJestConfig(customJestConfig)()), |
| 56 | + /** |
| 57 | + * @link https://github.com/vercel/next.js/issues/36077#issuecomment-1096698456 |
| 58 | + * @link https://jestjs.io/docs/ecmascript-modules |
| 59 | + */ |
| 60 | + transformIgnorePatterns: ['/node_modules/(?!(wagmi|@wagmi)/)'], |
| 61 | +}); |
0 commit comments