Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 5 additions & 25 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
import type { Config } from '@jest/types';
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: '<rootDir>/packages/toolpad-app',
});
const config: Config.InitialOptions = {
projects: ['<rootDir>/packages/toolpad-app/jest.config.js'],
setupFilesAfterEnv: ['<rootDir>/test/utils/jest-setup.ts'],
};

export default async function createConfig() {
const nextJestConfig: Config.InitialOptions = await createJestConfig({
testEnvironment: 'jest-environment-jsdom',
})();

// Workaround, see https://github.com/vercel/next.js/issues/35634#issuecomment-1115250297
nextJestConfig.transformIgnorePatterns[0] = '/node_modules/(?!lodash-es)/';

const config: Config.InitialOptions = {
projects: [
{
testMatch: ['<rootDir>/packages/toolpad-app/**/*.spec.*'],
...nextJestConfig,
},
],
setupFilesAfterEnv: ['<rootDir>/test/utils/jest-setup.ts'],
};

return config;
}
export default config;
14 changes: 14 additions & 0 deletions packages/toolpad-app/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const nextJest = require('next/jest');

const createJestConfig = nextJest();

async function jestConfig() {
const nextJestConfig = await createJestConfig({
testEnvironment: 'jest-environment-jsdom',
})();
// Workaround, see https://github.com/vercel/next.js/issues/35634#issuecomment-1115250297
nextJestConfig.transformIgnorePatterns[0] = '/node_modules/(?!lodash-es)/';
return nextJestConfig;
}

module.exports = jestConfig;