From 24556f6182dd45f65779c3a347b03d828bb11741 Mon Sep 17 00:00:00 2001 From: Caleb Ukle Date: Mon, 24 Apr 2023 14:51:38 -0500 Subject: [PATCH] fix(nextjs): ignore components in appDir when generating cy files --- .../cypress-component-configuration.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/next/src/generators/cypress-component-configuration/cypress-component-configuration.ts b/packages/next/src/generators/cypress-component-configuration/cypress-component-configuration.ts index 6645bb3be2b43..2458fbb58c132 100644 --- a/packages/next/src/generators/cypress-component-configuration/cypress-component-configuration.ts +++ b/packages/next/src/generators/cypress-component-configuration/cypress-component-configuration.ts @@ -15,6 +15,7 @@ import { isComponent } from '@nx/react/src/utils/ct-utils'; import { CypressComponentConfigurationGeneratorSchema } from './schema'; import { nxVersion } from '../../utils/versions'; import { componentTestGenerator } from '@nx/react'; +import { normalize, relative } from 'path'; export async function cypressComponentConfiguration( tree: Tree, @@ -99,8 +100,14 @@ async function addFiles( if (opts.generateTests) { const filePaths = []; visitNotIgnoredFiles(tree, projectConfig.sourceRoot, (filePath) => { - // we don't generate tests for pages/server-side components - if (filePath.includes('pages') || filePath.includes('server')) { + const fromProjectRootPath = relative(projectConfig.root, filePath); + console.log({ fromProjectRootPath, filePath }); + // we don't generate tests for pages/server-side/appDir components + if ( + fromProjectRootPath.includes('pages') || + fromProjectRootPath.includes('server') || + fromProjectRootPath.includes('app') + ) { return; }