/ jest.config.js
jest.config.js
 1  /* eslint-disable-next-line @typescript-eslint/no-var-requires */
 2  const nextJest = require('next/jest');
 3  
 4  // See: https://nextjs.org/docs/testing#jest-and-react-testing-library
 5  const createJestConfig = nextJest({
 6    // Provide the path to your Next.js app to load next.config.js and .env files in your test environment
 7    dir: './',
 8  });
 9  
10  // Add any custom config to be passed to Jest
11  const customJestConfig = {
12    // add our setup file
13    setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
14    // add support for alias' to work, since we use baseUrl in tsconfig.json
15    moduleDirectories: ['node_modules', '<rootDir>/'],
16    testEnvironment: 'jest-environment-jsdom',
17    // test any .test file in any `__tests__` directory, ignore cypress .spec files
18    testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+test.[jt]s?(x)'],
19    moduleNameMapper: {
20      'd3-time-format': '<rootDir>/node_modules/d3-time-format/dist/d3-time-format.min.js',
21      'd3-time': '<rootDir>/node_modules/d3-time/dist/d3-time.min.js',
22    },
23  };
24  
25  // createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
26  module.exports = createJestConfig(customJestConfig);