diff --git a/jest.config.ts b/jest.config.ts index cab1727e728..637bf2ea0d8 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -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: '/packages/toolpad-app', -}); +const config: Config.InitialOptions = { + projects: ['/packages/toolpad-app/jest.config.js'], + setupFilesAfterEnv: ['/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: ['/packages/toolpad-app/**/*.spec.*'], - ...nextJestConfig, - }, - ], - setupFilesAfterEnv: ['/test/utils/jest-setup.ts'], - }; - - return config; -} +export default config; diff --git a/packages/toolpad-app/jest.config.js b/packages/toolpad-app/jest.config.js new file mode 100644 index 00000000000..edd96fa7bee --- /dev/null +++ b/packages/toolpad-app/jest.config.js @@ -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;