From 3f1630b55945a5f7b514aecc25460a88e52117b3 Mon Sep 17 00:00:00 2001 From: Caleb Ukle Date: Wed, 2 Aug 2023 11:29:31 -0500 Subject: [PATCH 1/4] fix(testing): ensure playwright plugin public access --- packages/playwright/package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/playwright/package.json b/packages/playwright/package.json index 731199315b8cd..ac5338062d8b5 100644 --- a/packages/playwright/package.json +++ b/packages/playwright/package.json @@ -4,6 +4,9 @@ "type": "commonjs", "homepage": "https://nx.dev", "private": false, + "publishConfig": { + "access": "public" + }, "description": "The Nx Plugin for Playwright contains executors and generators allowing your workspace to use the powerful Playwright integration testing capabilities.", "keywords": [ "Monorepo", From 94ad16dbb81b860496721a4a2391d7c677c88b28 Mon Sep 17 00:00:00 2001 From: Caleb Ukle Date: Wed, 2 Aug 2023 11:31:39 -0500 Subject: [PATCH 2/4] chore(angular): cleanup from playwright PR --- packages/angular/project.json | 2 +- packages/angular/src/generators/application/lib/add-e2e.ts | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/angular/project.json b/packages/angular/project.json index 29896cc593235..e450027032e11 100644 --- a/packages/angular/project.json +++ b/packages/angular/project.json @@ -74,5 +74,5 @@ }, "lint": {} }, - "implicitDependencies": ["workspace", "playwright", "cypress", "jest"] + "implicitDependencies": [] } diff --git a/packages/angular/src/generators/application/lib/add-e2e.ts b/packages/angular/src/generators/application/lib/add-e2e.ts index 51eb32037e1f3..525423384b562 100644 --- a/packages/angular/src/generators/application/lib/add-e2e.ts +++ b/packages/angular/src/generators/application/lib/add-e2e.ts @@ -11,14 +11,12 @@ import { import { nxVersion } from '../../../utils/versions'; import type { NormalizedSchema } from './normalized-schema'; import { removeScaffoldedE2e } from './remove-scaffolded-e2e'; +import { cypressProjectGenerator } from '@nx/cypress'; export async function addE2e(tree: Tree, options: NormalizedSchema) { removeScaffoldedE2e(tree, options, options.ngCliSchematicE2ERoot); if (options.e2eTestRunner === 'cypress') { - const { cypressProjectGenerator } = ensurePackage< - typeof import('@nx/cypress') - >('@nx/cypress', nxVersion); // TODO: This can call `@nx/web:static-config` generator when ready addFileServerTarget(tree, options, 'serve-static'); From 5491b35364554d0b821049f57d2af411f67e9d87 Mon Sep 17 00:00:00 2001 From: Caleb Ukle Date: Wed, 2 Aug 2023 12:13:10 -0500 Subject: [PATCH 3/4] feat(testing): add option to install playwright browsers --- .../playwright/executors/playwright.json | 5 +++++ .../packages/playwright/generators/init.json | 5 +++++ e2e/angular-core/src/projects.test.ts | 2 -- .../src/executors/playwright/playwright.ts | 22 ++++++++++++++++--- .../src/executors/playwright/schema.json | 5 +++++ .../playwright/src/generators/init/init.ts | 15 +++++++++++++ .../src/generators/init/schema.d.ts | 1 + .../src/generators/init/schema.json | 5 +++++ 8 files changed, 55 insertions(+), 5 deletions(-) diff --git a/docs/generated/packages/playwright/executors/playwright.json b/docs/generated/packages/playwright/executors/playwright.json index 3d629fe8d9d7d..7a2a7d628955a 100644 --- a/docs/generated/packages/playwright/executors/playwright.json +++ b/docs/generated/packages/playwright/executors/playwright.json @@ -150,6 +150,11 @@ "uiPort": { "type": "string", "description": "Port to serve UI on, 0 for any free port; specifying this option opens UI in a browser tab" + }, + "skipInstall": { + "type": "boolean", + "description": "Skip running playwright install before running playwright tests. This is to ensure that playwright browsers are installed before running tests.", + "default": false } }, "required": [], diff --git a/docs/generated/packages/playwright/generators/init.json b/docs/generated/packages/playwright/generators/init.json index d658115c08499..7fdb074036fc6 100644 --- a/docs/generated/packages/playwright/generators/init.json +++ b/docs/generated/packages/playwright/generators/init.json @@ -19,6 +19,11 @@ "default": false, "description": "Do not add dependencies to `package.json`.", "x-priority": "internal" + }, + "skipInstall": { + "type": "boolean", + "description": "Skip running `playwright install`. This is to ensure that playwright browsers are installed.", + "default": false } }, "required": [], diff --git a/e2e/angular-core/src/projects.test.ts b/e2e/angular-core/src/projects.test.ts index b5e8de7a3579e..7842ce4618f8b 100644 --- a/e2e/angular-core/src/projects.test.ts +++ b/e2e/angular-core/src/projects.test.ts @@ -2,7 +2,6 @@ import { names } from '@nx/devkit'; import { checkFilesExist, cleanupProject, - ensurePlaywrightBrowsersInstallation, getSize, killPorts, killProcessAndPorts, @@ -132,7 +131,6 @@ describe('Angular Projects', () => { ); if (runCypressTests()) { - ensurePlaywrightBrowsersInstallation(); const e2eResults = runCLI(`e2e ${app}-e2e`); expect(e2eResults).toContain( `Successfully ran target e2e for project ${app}-e2e` diff --git a/packages/playwright/src/executors/playwright/playwright.ts b/packages/playwright/src/executors/playwright/playwright.ts index 8d74e8fa84d21..7dc18423d0351 100644 --- a/packages/playwright/src/executors/playwright/playwright.ts +++ b/packages/playwright/src/executors/playwright/playwright.ts @@ -1,6 +1,11 @@ -import { fork } from 'child_process'; -import { ExecutorContext, names } from '@nx/devkit'; -import { join } from 'path'; +import { execSync, fork } from 'child_process'; +import { + ExecutorContext, + getPackageManagerCommand, + names, + output, + workspaceRoot, +} from '@nx/devkit'; export interface PlaywrightExecutorSchema { /* @@ -49,6 +54,7 @@ export interface PlaywrightExecutorSchema { ui?: boolean; uiHost?: string; uiPort?: string; + skipInstall?: boolean; } export async function playwrightExecutor( @@ -63,6 +69,16 @@ export async function playwrightExecutor( `Unable to find the Project Root for ${context.projectName}. Is it set in the project.json?` ); } + + if (!options.skipInstall) { + output.log({ + title: 'Ensuring Playwright is installed.', + bodyLines: ['use --skipInstall to skip installation.'], + }); + const pmc = getPackageManagerCommand(); + execSync(`${pmc.exec} playwright install`, { cwd: workspaceRoot }); + } + const args = createArgs(options); const p = runPlaywright(args, context.root); diff --git a/packages/playwright/src/executors/playwright/schema.json b/packages/playwright/src/executors/playwright/schema.json index e73ab3f1fc99a..726f7e14ca576 100644 --- a/packages/playwright/src/executors/playwright/schema.json +++ b/packages/playwright/src/executors/playwright/schema.json @@ -149,6 +149,11 @@ "uiPort": { "type": "string", "description": "Port to serve UI on, 0 for any free port; specifying this option opens UI in a browser tab" + }, + "skipInstall": { + "type": "boolean", + "description": "Skip running playwright install before running playwright tests. This is to ensure that playwright browsers are installed before running tests.", + "default": false } }, "required": [] diff --git a/packages/playwright/src/generators/init/init.ts b/packages/playwright/src/generators/init/init.ts index 085d4b083ab03..dc7826cc7f1a7 100644 --- a/packages/playwright/src/generators/init/init.ts +++ b/packages/playwright/src/generators/init/init.ts @@ -3,12 +3,16 @@ import { convertNxGenerator, formatFiles, GeneratorCallback, + getPackageManagerCommand, + output, runTasksInSerial, Tree, updateJson, + workspaceRoot, } from '@nx/devkit'; import { InitGeneratorSchema } from './schema'; import { nxVersion, playwrightVersion } from '../../utils/versions'; +import { execSync } from 'child_process'; export async function initGenerator(tree: Tree, options: InitGeneratorSchema) { const tasks: GeneratorCallback[] = []; @@ -51,6 +55,17 @@ export async function initGenerator(tree: Tree, options: InitGeneratorSchema) { ); } + if (!options.skipInstall) { + tasks.push(() => { + output.log({ + title: 'Ensuring Playwright is installed.', + bodyLines: ['use --skipInstall to skip installation.'], + }); + const pmc = getPackageManagerCommand(); + execSync(`${pmc.exec} playwright install`, { cwd: workspaceRoot }); + }); + } + return runTasksInSerial(...tasks); } diff --git a/packages/playwright/src/generators/init/schema.d.ts b/packages/playwright/src/generators/init/schema.d.ts index 052f232474fb7..00e6d9ab7aacd 100644 --- a/packages/playwright/src/generators/init/schema.d.ts +++ b/packages/playwright/src/generators/init/schema.d.ts @@ -1,4 +1,5 @@ export interface InitGeneratorSchema { skipFormat: boolean; skipPackageJson: boolean; + skipInstall?: boolean; } diff --git a/packages/playwright/src/generators/init/schema.json b/packages/playwright/src/generators/init/schema.json index 7ba08b9d0d1a5..bf4e47e350115 100644 --- a/packages/playwright/src/generators/init/schema.json +++ b/packages/playwright/src/generators/init/schema.json @@ -16,6 +16,11 @@ "default": false, "description": "Do not add dependencies to `package.json`.", "x-priority": "internal" + }, + "skipInstall": { + "type": "boolean", + "description": "Skip running `playwright install`. This is to ensure that playwright browsers are installed.", + "default": false } }, "required": [] From 9bd5e542c8d40bcdb016f1bfc2112ee6709fb5ba Mon Sep 17 00:00:00 2001 From: Caleb Ukle Date: Wed, 2 Aug 2023 12:40:58 -0500 Subject: [PATCH 4/4] chore(repo): change NX_E2E_RUN_CYPRESS to NX_E2E_RUN_E2E including renaming fns like runCypressTests to runE2ETests --- .circleci/config.yml | 2 +- .github/workflows/e2e-matrix.yml | 2 +- .github/workflows/e2e-windows.yml | 2 +- e2e/angular-core/src/projects.test.ts | 6 +++--- .../src/cypress-component-tests.test.ts | 14 +++++++------- e2e/cypress/src/cypress.test.ts | 6 +++--- e2e/next/src/next-component-tests.test.ts | 14 +++++++------- e2e/next/src/utils.ts | 4 ++-- .../src/react-module-federation.test.ts | 1 - e2e/react-core/src/react.test.ts | 4 ++-- .../src/cypress-component-tests.test.ts | 14 +++++++------- e2e/utils/command-utils.ts | 17 +++++++++++++---- e2e/web/src/web-vite.test.ts | 4 ++-- e2e/web/src/web.test.ts | 6 +++--- 14 files changed, 52 insertions(+), 44 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index ec4547ba3486f..341cd2ac87943 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -132,7 +132,7 @@ jobs: GIT_COMMITTER_NAME: Test NX_E2E_CI_CACHE_KEY: e2e-circleci-<< parameters.os >> SELECTED_PM: << parameters.pm >> - NX_E2E_RUN_CYPRESS: 'true' + NX_E2E_RUN_E2E: 'true' NX_VERBOSE_LOGGING: 'false' NX_NATIVE_LOGGING: 'false' NX_PERF_LOGGING: 'false' diff --git a/.github/workflows/e2e-matrix.yml b/.github/workflows/e2e-matrix.yml index 3d328b33a54c5..6d1b744d2349c 100644 --- a/.github/workflows/e2e-matrix.yml +++ b/.github/workflows/e2e-matrix.yml @@ -415,7 +415,7 @@ jobs: YARN_REGISTRY: http://localhost:4872 NX_CACHE_DIRECTORY: 'tmp' NX_E2E_SKIP_BUILD_CLEANUP: 'true' - NX_E2E_RUN_CYPRESS: 'true' + NX_E2E_RUN_E2E: 'true' NX_E2E_VERBOSE_LOGGING: 'true' NX_PERF_LOGGING: 'false' NX_DAEMON: 'true' diff --git a/.github/workflows/e2e-windows.yml b/.github/workflows/e2e-windows.yml index 2d57eefb068d9..4165c5faabea4 100644 --- a/.github/workflows/e2e-windows.yml +++ b/.github/workflows/e2e-windows.yml @@ -303,7 +303,7 @@ jobs: npm_config_registry: http://localhost:4872 NX_CACHE_DIRECTORY: 'tmp' NX_E2E_SKIP_BUILD_CLEANUP: 'true' - NX_E2E_RUN_CYPRESS: 'true' + NX_E2E_RUN_E2E: 'true' NX_E2E_VERBOSE_LOGGING: 'true' NX_PERF_LOGGING: 'false' NX_DAEMON: 'true' diff --git a/e2e/angular-core/src/projects.test.ts b/e2e/angular-core/src/projects.test.ts index 7842ce4618f8b..3945a4b0eb693 100644 --- a/e2e/angular-core/src/projects.test.ts +++ b/e2e/angular-core/src/projects.test.ts @@ -10,7 +10,7 @@ import { removeFile, runCLI, runCommandUntil, - runCypressTests, + runE2ETests, tmpProjPath, uniq, updateFile, @@ -97,7 +97,7 @@ describe('Angular Projects', () => { ); // check e2e tests - if (runCypressTests()) { + if (runE2ETests()) { const e2eResults = runCLI(`e2e ${app1}-e2e --no-watch`); expect(e2eResults).toContain('All specs passed!'); expect(await killPorts()).toBeTruthy(); @@ -130,7 +130,7 @@ describe('Angular Projects', () => { `generate @nx/angular:app ${app} --e2eTestRunner=playwright --no-interactive` ); - if (runCypressTests()) { + if (runE2ETests()) { const e2eResults = runCLI(`e2e ${app}-e2e`); expect(e2eResults).toContain( `Successfully ran target e2e for project ${app}-e2e` diff --git a/e2e/angular-extensions/src/cypress-component-tests.test.ts b/e2e/angular-extensions/src/cypress-component-tests.test.ts index c5a19786bdef0..91fef23dfbfec 100644 --- a/e2e/angular-extensions/src/cypress-component-tests.test.ts +++ b/e2e/angular-extensions/src/cypress-component-tests.test.ts @@ -4,7 +4,7 @@ import { createFile, newProject, runCLI, - runCypressTests, + runE2ETests, uniq, updateFile, updateProjectConfig, @@ -39,7 +39,7 @@ describe('Angular Cypress Component Tests', () => { runCLI( `generate @nx/angular:cypress-component-configuration --project=${appName} --generate-tests --no-interactive` ); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${appName} --no-watch`)).toContain( 'All specs passed!' ); @@ -50,7 +50,7 @@ describe('Angular Cypress Component Tests', () => { runCLI( `generate @nx/angular:cypress-component-configuration --project=${usedInAppLibName} --generate-tests --no-interactive` ); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${usedInAppLibName} --no-watch`)).toContain( 'All specs passed!' ); @@ -70,7 +70,7 @@ describe('Angular Cypress Component Tests', () => { runCLI( `generate @nx/angular:cypress-component-configuration --project=${buildableLibName} --generate-tests --build-target=${appName}:build --no-interactive` ); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${buildableLibName} --no-watch`)).toContain( 'All specs passed!' ); @@ -92,7 +92,7 @@ describe('Angular Cypress Component Tests', () => { } ); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${buildableLibName} --no-watch`)).toContain( 'All specs passed!' ); @@ -108,7 +108,7 @@ describe('Angular Cypress Component Tests', () => { updateBuilableLibTestsToAssertAppStyles(appName, buildableLibName); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${buildableLibName} --no-watch`)).toContain( 'All specs passed!' ); @@ -122,7 +122,7 @@ describe('Angular Cypress Component Tests', () => { checkFilesExist('tailwind.config.js'); checkFilesDoNotExist(`libs/${buildableLibName}/tailwind.config.js`); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${buildableLibName} --no-watch`)).toContain( 'All specs passed!' ); diff --git a/e2e/cypress/src/cypress.test.ts b/e2e/cypress/src/cypress.test.ts index f596d3c2def6e..965ad5fe5049c 100644 --- a/e2e/cypress/src/cypress.test.ts +++ b/e2e/cypress/src/cypress.test.ts @@ -8,7 +8,7 @@ import { newProject, readJson, runCLI, - runCypressTests, + runE2ETests, uniq, updateFile, updateJson, @@ -200,7 +200,7 @@ async function testCtAndE2eInProject( `generate @nx/${projectType}:cypress-component-configuration --project=${appName} --generate-tests --no-interactive` ); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`run ${appName}:component-test --no-watch`)).toContain( 'All specs passed!' ); @@ -208,7 +208,7 @@ async function testCtAndE2eInProject( runCLI(`generate @nx/cypress:e2e --project=${appName} --no-interactive`); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`run ${appName}:e2e --no-watch`)).toContain( 'All specs passed!' ); diff --git a/e2e/next/src/next-component-tests.test.ts b/e2e/next/src/next-component-tests.test.ts index 1c7ce8ea1a914..a7e1106e8f9a0 100644 --- a/e2e/next/src/next-component-tests.test.ts +++ b/e2e/next/src/next-component-tests.test.ts @@ -2,7 +2,7 @@ import { createFile, newProject, runCLI, - runCypressTests, + runE2ETests, uniq, updateFile, } from '@nx/e2e/utils'; @@ -17,13 +17,13 @@ describe('NextJs Component Testing', () => { it('should test a NextJs app', () => { const appName = uniq('next-app'); createAppWithCt(appName); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${appName} --no-watch`)).toContain( 'All specs passed!' ); } addTailwindToApp(appName); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${appName} --no-watch`)).toContain( 'All specs passed!' ); @@ -33,13 +33,13 @@ describe('NextJs Component Testing', () => { it('should test a NextJs lib', async () => { const libName = uniq('next-lib'); createLibWithCt(libName, false); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${libName} --no-watch`)).toContain( 'All specs passed!' ); } addTailwindToLib(libName); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${libName} --no-watch`)).toContain( 'All specs passed!' ); @@ -49,14 +49,14 @@ describe('NextJs Component Testing', () => { it('should test a NextJs buildable lib', async () => { const buildableLibName = uniq('next-buildable-lib'); createLibWithCt(buildableLibName, true); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${buildableLibName} --no-watch`)).toContain( 'All specs passed!' ); } addTailwindToLib(buildableLibName); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${buildableLibName} --no-watch`)).toContain( 'All specs passed!' ); diff --git a/e2e/next/src/utils.ts b/e2e/next/src/utils.ts index 343f6116e8775..028fcbbb8e66f 100644 --- a/e2e/next/src/utils.ts +++ b/e2e/next/src/utils.ts @@ -4,7 +4,7 @@ import { readJson, runCLI, runCLIAsync, - runCypressTests, + runE2ETests, } from '../../utils'; export async function checkApp( @@ -40,7 +40,7 @@ export async function checkApp( expect(packageJson.dependencies['react-dom']).toBeDefined(); expect(packageJson.dependencies.next).toBeDefined(); - if (opts.checkE2E && runCypressTests()) { + if (opts.checkE2E && runE2ETests()) { const e2eResults = runCLI( `e2e ${appName}-e2e --no-watch --configuration=production` ); diff --git a/e2e/react-core/src/react-module-federation.test.ts b/e2e/react-core/src/react-module-federation.test.ts index f078a3a513f62..8c45c5bcfafb3 100644 --- a/e2e/react-core/src/react-module-federation.test.ts +++ b/e2e/react-core/src/react-module-federation.test.ts @@ -7,7 +7,6 @@ import { readProjectConfig, runCLI, runCLIAsync, - runCypressTests, uniq, updateFile, } from '@nx/e2e/utils'; diff --git a/e2e/react-core/src/react.test.ts b/e2e/react-core/src/react.test.ts index c508837e4d93e..4849f47b7c509 100644 --- a/e2e/react-core/src/react.test.ts +++ b/e2e/react-core/src/react.test.ts @@ -9,7 +9,7 @@ import { readFile, runCLI, runCLIAsync, - runCypressTests, + runE2ETests, uniq, updateFile, updateJson, @@ -363,7 +363,7 @@ async function testGeneratedApp( 'Test Suites: 1 passed, 1 total' ); - if (opts.checkE2E && runCypressTests()) { + if (opts.checkE2E && runE2ETests()) { const e2eResults = runCLI(`e2e ${appName}-e2e --no-watch`); expect(e2eResults).toContain('All specs passed!'); expect(await killPorts()).toBeTruthy(); diff --git a/e2e/react-extensions/src/cypress-component-tests.test.ts b/e2e/react-extensions/src/cypress-component-tests.test.ts index 134889ffd9b8e..85e58fd7b4157 100644 --- a/e2e/react-extensions/src/cypress-component-tests.test.ts +++ b/e2e/react-extensions/src/cypress-component-tests.test.ts @@ -4,7 +4,7 @@ import { ensureCypressInstallation, newProject, runCLI, - runCypressTests, + runE2ETests, uniq, updateFile, updateJson, @@ -147,7 +147,7 @@ export default Input; runCLI( `generate @nx/react:cypress-component-configuration --project=${appName} --generate-tests` ); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${appName} --no-watch`)).toContain( 'All specs passed!' ); @@ -158,7 +158,7 @@ export default Input; runCLI( `generate @nx/react:cypress-component-configuration --project=${usedInAppLibName} --generate-tests` ); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${usedInAppLibName} --no-watch`)).toContain( 'All specs passed!' ); @@ -190,7 +190,7 @@ describe(Input.name, () => { `generate @nx/react:cypress-component-configuration --project=${buildableLibName} --generate-tests --build-target=${appName}:build` ); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${buildableLibName} --no-watch`)).toContain( 'All specs passed!' ); @@ -221,7 +221,7 @@ ${content}`; } ); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${buildableLibName} --no-watch`)).toContain( 'All specs passed!' ); @@ -260,7 +260,7 @@ ${content}`; return config; }); - if (runCypressTests()) { + if (runE2ETests()) { const results = runCLI(`component-test ${appName}`); expect(results).toContain('I am from the custom async Webpack config'); expect(results).toContain('All specs passed!'); @@ -291,7 +291,7 @@ export default MyComponent;`; runCLI( `generate @nrwl/react:cypress-component-configuration --project=${viteLibName} --generate-tests --bundler=vite --build-target=${appName}:build` ); - if (runCypressTests()) { + if (runE2ETests()) { expect(runCLI(`component-test ${viteLibName}`)).toContain( 'All specs passed!' ); diff --git a/e2e/utils/command-utils.ts b/e2e/utils/command-utils.ts index f87350f610353..67057b78874c4 100644 --- a/e2e/utils/command-utils.ts +++ b/e2e/utils/command-utils.ts @@ -3,6 +3,7 @@ import { packageInstall, tmpProjPath } from './create-project-utils'; import { detectPackageManager, ensureCypressInstallation, + ensurePlaywrightBrowsersInstallation, getNpmMajorVersion, getPublishedVersion, getStrippedEnvironmentVariables, @@ -175,15 +176,23 @@ export function getPackageManagerCommand({ }[packageManager.trim() as PackageManager]; } -export function runCypressTests() { - if (process.env.NX_E2E_RUN_CYPRESS === 'true') { +export function runE2ETests() { + if (process.env.NX_E2E_RUN_E2E === 'true') { ensureCypressInstallation(); + ensurePlaywrightBrowsersInstallation(); return true; - } else { + } + + console.warn( + 'Not running E2E tests because NX_E2E_RUN_E2E is not set to true.' + ); + + if (process.env.NX_E2E_RUN_CYPRESS) { console.warn( - 'Not running Cypress because NX_E2E_RUN_CYPRESS is not set to true.' + 'NX_E2E_RUN_CYPRESS is deprecated, use NX_E2E_RUN_E2E instead.' ); } + return false; } diff --git a/e2e/web/src/web-vite.test.ts b/e2e/web/src/web-vite.test.ts index 7bba72a225ca1..5038cbd2c64d6 100644 --- a/e2e/web/src/web-vite.test.ts +++ b/e2e/web/src/web-vite.test.ts @@ -9,7 +9,7 @@ import { removeFile, runCLI, runCLIAsync, - runCypressTests, + runE2ETests, uniq, } from '@nx/e2e/utils'; @@ -35,7 +35,7 @@ describe('Web Components Applications with bundler set as vite', () => { expect(lintE2eResults).toContain('All files pass linting.'); - if (isNotWindows() && runCypressTests()) { + if (isNotWindows() && runE2ETests()) { const e2eResults = runCLI(`e2e ${appName}-e2e --no-watch`); expect(e2eResults).toContain('All specs passed!'); expect(await killPorts()).toBeTruthy(); diff --git a/e2e/web/src/web.test.ts b/e2e/web/src/web.test.ts index 34bb1e3e4a004..6fd426ac229f1 100644 --- a/e2e/web/src/web.test.ts +++ b/e2e/web/src/web.test.ts @@ -12,7 +12,7 @@ import { rmDist, runCLI, runCLIAsync, - runCypressTests, + runE2ETests, tmpProjPath, uniq, updateFile, @@ -43,7 +43,7 @@ describe('Web Components Applications', () => { expect(lintE2eResults).toContain('All files pass linting.'); - if (isNotWindows() && runCypressTests()) { + if (isNotWindows() && runE2ETests()) { const e2eResults = runCLI(`e2e ${appName}-e2e --no-watch`); expect(e2eResults).toContain('All specs passed!'); expect(await killPorts()).toBeTruthy(); @@ -109,7 +109,7 @@ describe('Web Components Applications', () => { expect(lintE2eResults).toContain('All files pass linting.'); - if (isNotWindows() && runCypressTests()) { + if (isNotWindows() && runE2ETests()) { ensurePlaywrightBrowsersInstallation(); const e2eResults = runCLI(`e2e ${appName}-e2e`); expect(e2eResults).toContain(