ui phase 1
This commit is contained in:
+20
-2
@@ -24,5 +24,23 @@ const customJestConfig: Config = {
|
||||
// },
|
||||
};
|
||||
|
||||
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
|
||||
module.exports = createJestConfig(customJestConfig);
|
||||
// next-intl (and its use-intl dependency) ship ESM-only builds. next/jest's own
|
||||
// `transformIgnorePatterns` already broadly matches all of node_modules (its negative-lookahead
|
||||
// allowlist only carves out a couple of Next.js-internal packages), and Jest's array semantics
|
||||
// are OR-based — a file is ignored if ANY pattern matches, so appending a more permissive pattern
|
||||
// can never "un-ignore" a package an earlier pattern already caught. The array has to be replaced
|
||||
// outright (post-processing the async config next/jest returns), not merged, to let a real
|
||||
// (unmocked) `import ... from 'next-intl'` be transformed instead of failing to parse. Without
|
||||
// this, any shared component that imports next-intl (even just for a sensible default) would
|
||||
// force every test file that transitively imports it via the `@/components` barrel to
|
||||
// `jest.mock('next-intl', …)`, even when that test never touches translations itself.
|
||||
const withTransformableIntl = async () => {
|
||||
const config = await createJestConfig(customJestConfig)();
|
||||
config.transformIgnorePatterns = [
|
||||
'/node_modules/(?!(geist|next/dist/client|next/dist/shared/lib|next/src/client|next/src/shared/lib|next-intl|use-intl|@formatjs|intl-messageformat)/)',
|
||||
'^.+\\.module\\.(css|sass|scss)$',
|
||||
];
|
||||
return config;
|
||||
};
|
||||
|
||||
module.exports = withTransformableIntl;
|
||||
|
||||
Reference in New Issue
Block a user