Skip to content

Commit

Permalink
fix(nextjs): ensure next apps config is correctly checked when using …
Browse files Browse the repository at this point in the history
…jest

closes: #29035
  • Loading branch information
ndcunningham committed Nov 25, 2024
1 parent 9526560 commit ec91f8e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/jest/src/generators/configuration/lib/update-tsconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ export function updateTsConfig(
root,
options.runtimeTsconfigFileName
);
// If the app is Next.js it will not have a tsconfig.app.json
const extensions = ['js', 'ts', 'mjs', 'cjs'];
const hasNextConfig = extensions.some((ext) =>
host.exists(joinPathFragments(root, `next.config.${ext}`))
);

if (hasNextConfig && projectType === 'application') {
runtimeTsconfigPath = joinPathFragments(root, 'tsconfig.json');
}

if (!host.exists(runtimeTsconfigPath)) {
// the user provided a runtimeTsconfigFileName that doesn't exist, so we throw an error
throw new Error(
Expand Down

0 comments on commit ec91f8e

Please sign in to comment.