This repository has been archived by the owner on Jul 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.ts
46 lines (40 loc) · 1.56 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
import type { Config } from '@jest/types';
// Next documentation of testing:
// https://nextjs.org/docs/testing#setting-up-jest-with-babel=
const config: Config.InitialOptions = {
verbose: true,
collectCoverage: false,
coverageProvider: 'v8',
collectCoverageFrom: [
'**/*.{js,jsx,ts,tsx}',
'!**/*.d.ts',
'!**/node_modules/**',
'!<rootDir>/out/**',
'!<rootDir>/.next/**',
'!<rootDir>/tests/**',
'!<rootDir>/*.config.{js,ts}',
'!<rootDir>/coverage/**',
],
moduleNameMapper: {
// Handle CSS imports (with CSS modules)
// https://jestjs.io/docs/webpack#mocking-css-modules
'^.+\\.module\\.(css|sass|scss)$': '<rootDir>/tests/mocks/style.js',
// Handle CSS imports (without CSS modules)
'^.+\\.(css|sass|scss)$': '<rootDir>/tests/mocks/style.js',
// Handle image imports
// https://jestjs.io/docs/webpack#handling-static-assets
'\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/tests/mocks/file.js',
'\\.svg$': '<rootDir>/tests/mocks/svg.js',
},
// Add more setup options before each test is run
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
testPathIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/.next/'],
testEnvironment: 'jsdom',
transform: {
// Use babel-jest to transpile tests, babel will use the `babel.config.js`.
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
},
// Jest will skip `node_modules` by default, but we need to override this behavior
transformIgnorePatterns: ['^.+\\.module\\.(css|sass|scss)$'],
};
export default config;