-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjest.config.ts
49 lines (43 loc) · 1.97 KB
/
jest.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { Config } from 'jest';
import nextJest from 'next/jest';
const createJestConfig = nextJest({
/* Provide the path to your Next.js app to load next.config.js and .env files in your test environment */
dir: './',
});
const namespacesToTransform = ['preact', '@ensdomains', 'multiformats', '@walletconnect'];
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/
const customJestConfig: Config = {
verbose: true,
rootDir: './',
testEnvironment: 'jest-environment-jsdom',
preset: 'ts-jest',
/* Add more setup options before each test is run */
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
snapshotSerializers: ['@emotion/jest/serializer'],
/* if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work */
moduleDirectories: ['node_modules', '<rootDir>/'],
/* test any .test file in any `__tests__` directory, ignore cypress .spec files */
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+test.[jt]s?(x)'],
transformIgnorePatterns: [`node_modules/(?!(${namespacesToTransform.join('|')})/)`],
clearMocks: true,
testPathIgnorePatterns: ['/.next/', '/node_modules/', '/__tests__/__utils__/', '__tests__/components/shared/compounds/SEO.test.tsx',
'__tests__/pages/admin/index.test.tsx'],
};
/*
* createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
* module.exports = createJestConfig(customJestConfig);
*/
const asyncConfig = createJestConfig(customJestConfig);
module.exports = async () => {
const config = await asyncConfig();
/*
* IMPORTANT: next/jest ignores node_modules and allows to add more ignore patterns, but
* we need to override them fully to whitelist some node_modules.
* See: https://github.com/vercel/next.js/blob/canary/packages/next/build/jest/jest.ts
*/
config.transformIgnorePatterns = customJestConfig.transformIgnorePatterns;
return config;
};