diff --git a/docs/generated/packages/cypress.json b/docs/generated/packages/cypress.json index 69c9b5c26d1d3..2642273f59c6b 100644 --- a/docs/generated/packages/cypress.json +++ b/docs/generated/packages/cypress.json @@ -17,13 +17,13 @@ "name": "Component Testing", "id": "cypress-component-testing", "file": "shared/cypress-component-testing", - "content": "# Cypress Component Testing\n\n> Component testing requires Cypress v10 and above.\n> See our [guide for more information](/cypress/v10-migration-guide) to migrate to Cypress v10.\n\nUnlike [E2E testing](/packages/cypress), component testing does not create a new project. Instead, Cypress component testing is added\ndirectly to a project, like [Jest](/packages/jest)\n\n## Add Component Testing to a Project\n\n> Currently only [@nrwl/react](/packages/react/generators/cypress-component-configuration) and [@nrwl/angular](/packages/angular/generators/cypress-component-configuration) plugins support component testing\n\nUse the `cypress-component-configuration` generator from the respective plugin to add component testing to a project.\n\n```shell\nnx g @nrwl/react:cypress-component-configuration --project=your-project\n\nnx g @nrwl/angular:cypress-component-configuration --project=your-project\n```\n\nYou can optionally pass in `--generate-tests` to create component tests for all components within the library.\n\nComponent testing leverages a build target within your workspace as the base for running the tests. The build target is usually an app within the workspace. By default, the generator attempts to find the build target for you based on the project usage, but you can manually specify the build target to use via the `--build-target` option.\n\n```shell\nnx g @nrwl/react:cypress-component-configuration --project=your-project --build-target=my-react-app:build\n\nnx g @nrwl/angular:cypress-component-configuration --project=your-project --build-target=my-ng-app:build\n```\n\nThe build target option can be changed later via updating the `devServerTarget` option in the `component-test` target.\n\n{% callout type=\"warning\" title=\"Executor Options\" %}\nWhen using component testing make sure to set `skipServe: true` in the component test target options, otherwise `@nrwl/cypress` will attempt to run the build first which can slow down your component tests. `skipServe: true` is automatically set when using the `cypress-component-configuration` generator.\n{% /callout %}\n\n## Testing Projects\n\nRun `nx component-test your-lib` to execute the component tests with Cypress.\n\nBy default, Cypress will run in headless mode. You will have the result of all the tests and errors (if any) in your\nterminal. Screenshots and videos will be accessible in `dist/cypress/libs/your-lib/screenshots` and `dist/cypress/libs/your-lib/videos`.\n\n## Watching for Changes (Headed Mode)\n\nWith, `nx component-test your-lib --watch` Cypress will start in headed mode. Where you can see your component being tested.\n\nRunning Cypress with `--watch` is a great way to iterate on your components since cypress will rerun your tests as you make those changes validating the new behavior.\n\n## More Information\n\nYou can read more on component testing in the [Cypress documentation](https://docs.cypress.io/guides/component-testing/writing-your-first-component-test).\n" + "content": "# Cypress Component Testing\n\n> Component testing requires Cypress v10 and above.\n> See our [guide for more information](/cypress/v11-migration-guide) to migrate to Cypress v10.\n\nUnlike [E2E testing](/packages/cypress), component testing does not create a new project. Instead, Cypress component testing is added\ndirectly to a project, like [Jest](/packages/jest)\n\n## Add Component Testing to a Project\n\n> Currently only [@nrwl/react](/packages/react/generators/cypress-component-configuration) and [@nrwl/angular](/packages/angular/generators/cypress-component-configuration) plugins support component testing\n\nUse the `cypress-component-configuration` generator from the respective plugin to add component testing to a project.\n\n```shell\nnx g @nrwl/react:cypress-component-configuration --project=your-project\n\nnx g @nrwl/angular:cypress-component-configuration --project=your-project\n```\n\nYou can optionally pass in `--generate-tests` to create component tests for all components within the library.\n\nComponent testing leverages a build target within your workspace as the base for running the tests. The build target is usually an app within the workspace. By default, the generator attempts to find the build target for you based on the project usage, but you can manually specify the build target to use via the `--build-target` option.\n\n```shell\nnx g @nrwl/react:cypress-component-configuration --project=your-project --build-target=my-react-app:build\n\nnx g @nrwl/angular:cypress-component-configuration --project=your-project --build-target=my-ng-app:build\n```\n\nThe build target option can be changed later via updating the `devServerTarget` option in the `component-test` target.\n\n{% callout type=\"warning\" title=\"Executor Options\" %}\nWhen using component testing make sure to set `skipServe: true` in the component test target options, otherwise `@nrwl/cypress` will attempt to run the build first which can slow down your component tests. `skipServe: true` is automatically set when using the `cypress-component-configuration` generator.\n{% /callout %}\n\n## Testing Projects\n\nRun `nx component-test your-lib` to execute the component tests with Cypress.\n\nBy default, Cypress will run in headless mode. You will have the result of all the tests and errors (if any) in your\nterminal. Screenshots and videos will be accessible in `dist/cypress/libs/your-lib/screenshots` and `dist/cypress/libs/your-lib/videos`.\n\n## Watching for Changes (Headed Mode)\n\nWith, `nx component-test your-lib --watch` Cypress will start in headed mode. Where you can see your component being tested.\n\nRunning Cypress with `--watch` is a great way to iterate on your components since cypress will rerun your tests as you make those changes validating the new behavior.\n\n## More Information\n\nYou can read more on component testing in the [Cypress documentation](https://docs.cypress.io/guides/component-testing/writing-your-first-component-test).\n" }, { - "name": "v10 Migration Guide", - "id": "v10-migration-guide", - "file": "shared/guides/cypress/cypress-v10-migration", - "content": "# Migrating to Cypress V10\n\nCypress v10 introduce new features, like component testing, along with some breaking changes.\n\nBefore continuing, make sure you have all your changes committed and have a clean working tree.\n\nYou can migrate an E2E project to v10 by running the following command:\n\n```shell\nnx g @nrwl/cypress:migrate-to-cypress-10\n```\n\nIn general, these are the steps taken to migrate your project:\n\n1. Migrates your existing `cypress.json` configuration to a new `cypress.config.ts` configuration file.\n - The `pluginsFile` option has been replaced for `setupNodeEvents`. We will import the file and add it to\n the `setupNodeEvents` config option. Double-check your plugins are working correctly.\n2. Rename all test files from `.spec.ts` to `.cy.ts`\n3. Rename the `support/index.ts` to `support/e2e.ts` and update any associated imports\n4. Rename the `integrations` folder to the `e2e` folder\n\n{% callout type=\"caution\" title=\"Root cypress.json\" %}\nKeeping a root `cypress.json` file, will cause issues with [Cypress trying to load the project](https://github.com/nrwl/nx/issues/11512).\nInstead, you can create a [root ts file and import it into each project's cypress config file](https://github.com/nrwl/nx/issues/11512#issuecomment-1213420638) to share values across projects.\n{% /callout %}\n\nWe take the best effort to make this migration seamless, but there can be edge cases we didn't anticipate. So feel free to [open an issue](https://github.com/nrwl/nx/issues/new?assignees=&labels=type%3A+bug&template=1-bug.md) if you come across any problems.\n\nYou can also consult the [official Cypress migration guide](https://docs.cypress.io/guides/references/migration-guide#Migrating-to-Cypress-version-10-0) if you get stuck and want to manually migrate your projects.\n" + "name": "v11 Migration Guide", + "id": "v11-migration-guide", + "file": "shared/guides/cypress/cypress-v11-migration", + "content": "# Migrating to Cypress V11\n\nCypress v10 introduce new features, like component testing, along with some breaking changes. Nx can help you migrate from v8 or v9 of Cypress to v10 and then to v11.\n\nBefore continuing, make sure you have all your changes committed and have a clean working tree.\n\nYou can migrate an E2E project to v11 by running the following command:\n\n```shell\nnx g @nrwl/cypress:migrate-to-cypress-11\n```\n\nIn general, these are the steps taken to migrate your project:\n\n1. Migrates your existing `cypress.json` configuration to a new `cypress.config.ts` configuration file.\n - The `pluginsFile` option has been replaced for `setupNodeEvents`. We will import the file and add it to\n the `setupNodeEvents` config option. Double-check your plugins are working correctly.\n2. Rename all test files from `.spec.ts` to `.cy.ts`\n3. Rename the `support/index.ts` to `support/e2e.ts` and update any associated imports\n4. Rename the `integrations` folder to the `e2e` folder\n\n{% callout type=\"caution\" title=\"Root cypress.json\" %}\nKeeping a root `cypress.json` file, will cause issues with [Cypress trying to load the project](https://github.com/nrwl/nx/issues/11512).\nInstead, you can create a [root ts file and import it into each project's cypress config file](https://github.com/nrwl/nx/issues/11512#issuecomment-1213420638) to share values across projects.\n{% /callout %}\n\nWe take the best effort to make this migration seamless, but there can be edge cases we didn't anticipate. So feel free to [open an issue](https://github.com/nrwl/nx/issues/new?assignees=&labels=type%3A+bug&template=1-bug.md) if you come across any problems.\n\nYou can also consult the [official Cypress migration guide](https://docs.cypress.io/guides/references/migration-guide#Migrating-to-Cypress-version-10-0) if you get stuck and want to manually migrate your projects.\n" } ], "generators": [ @@ -158,29 +158,29 @@ "path": "/packages/cypress/src/generators/cypress-component-project/schema.json" }, { - "name": "migrate-to-cypress-10", - "factory": "./src/generators/migrate-to-cypress-ten/migrate-to-cypress-ten#migrateCypressProject", + "name": "migrate-to-cypress-11", + "factory": "./src/generators/migrate-to-cypress-11/migrate-to-cypress-11#migrateCypressProject", "schema": { "$schema": "http://json-schema.org/schema", - "$id": "NxCypressMigrateToTen", + "$id": "NxCypressMigrateTo11", "cli": "nx", - "title": "Migrate e2e project to Cypress 10", - "description": "Migrate Cypress e2e project from v8/v9 to Cypress v10.", + "title": "Migrate e2e project to Cypress 11", + "description": "Migrate Cypress e2e project from v8/v9 to Cypress v11.", "type": "object", "examples": [ { - "command": "nx g @nrwl/cypress:migrate-to-cypress-10", - "description": "Migrate existing cypress projects to Cypress v10" + "command": "nx g @nrwl/cypress:migrate-to-cypress-11", + "description": "Migrate existing cypress projects to Cypress v11" } ], "properties": {}, "presets": [] }, - "description": "Migrate existing Cypress e2e projects to Cypress v10", - "hidden": true, - "implementation": "/packages/cypress/src/generators/migrate-to-cypress-ten/migrate-to-cypress-ten#migrateCypressProject.ts", + "description": "Migrate existing Cypress e2e projects to Cypress v11", + "implementation": "/packages/cypress/src/generators/migrate-to-cypress-11/migrate-to-cypress-11#migrateCypressProject.ts", "aliases": [], - "path": "/packages/cypress/src/generators/migrate-to-cypress-ten/schema.json" + "hidden": false, + "path": "/packages/cypress/src/generators/migrate-to-cypress-11/schema.json" } ], "executors": [ diff --git a/docs/map.json b/docs/map.json index 74358dca2cbc7..5f14d27983176 100644 --- a/docs/map.json +++ b/docs/map.json @@ -1579,9 +1579,9 @@ "file": "shared/cypress-component-testing" }, { - "name": "v10 Migration Guide", - "id": "v10-migration-guide", - "file": "shared/guides/cypress/cypress-v10-migration" + "name": "v11 Migration Guide", + "id": "v11-migration-guide", + "file": "shared/guides/cypress/cypress-v11-migration" } ] }, diff --git a/docs/packages.json b/docs/packages.json index 1a14f8f331b5e..d18c0cb3e33ed 100644 --- a/docs/packages.json +++ b/docs/packages.json @@ -91,7 +91,7 @@ "init", "cypress-project", "cypress-component-project", - "migrate-to-cypress-10" + "migrate-to-cypress-11" ] } }, diff --git a/docs/shared/cypress-component-testing.md b/docs/shared/cypress-component-testing.md index 7d378f646c9ba..833bbb434e33d 100644 --- a/docs/shared/cypress-component-testing.md +++ b/docs/shared/cypress-component-testing.md @@ -1,7 +1,7 @@ # Cypress Component Testing > Component testing requires Cypress v10 and above. -> See our [guide for more information](/cypress/v10-migration-guide) to migrate to Cypress v10. +> See our [guide for more information](/cypress/v11-migration-guide) to migrate to Cypress v10. Unlike [E2E testing](/packages/cypress), component testing does not create a new project. Instead, Cypress component testing is added directly to a project, like [Jest](/packages/jest) diff --git a/docs/shared/guides/cypress/cypress-v10-migration.md b/docs/shared/guides/cypress/cypress-v11-migration.md similarity index 87% rename from docs/shared/guides/cypress/cypress-v10-migration.md rename to docs/shared/guides/cypress/cypress-v11-migration.md index f6f7c6e105830..69519d2908e9b 100644 --- a/docs/shared/guides/cypress/cypress-v10-migration.md +++ b/docs/shared/guides/cypress/cypress-v11-migration.md @@ -1,13 +1,13 @@ -# Migrating to Cypress V10 +# Migrating to Cypress V11 -Cypress v10 introduce new features, like component testing, along with some breaking changes. +Cypress v10 introduce new features, like component testing, along with some breaking changes. Nx can help you migrate from v8 or v9 of Cypress to v10 and then to v11. Before continuing, make sure you have all your changes committed and have a clean working tree. -You can migrate an E2E project to v10 by running the following command: +You can migrate an E2E project to v11 by running the following command: ```shell -nx g @nrwl/cypress:migrate-to-cypress-10 +nx g @nrwl/cypress:migrate-to-cypress-11 ``` In general, these are the steps taken to migrate your project: diff --git a/nx-dev/nx-dev/redirect-rules.config.js b/nx-dev/nx-dev/redirect-rules.config.js index 2f137056baa22..33d2436a8c946 100644 --- a/nx-dev/nx-dev/redirect-rules.config.js +++ b/nx-dev/nx-dev/redirect-rules.config.js @@ -162,6 +162,7 @@ const guideUrls = { '/using-nx/nx-devkit': '/extending-nx/nx-devkit', '/structure/project-graph-plugins': '/extending-nx/project-graph-plugins', '/guides/lerna-and-nx': '/migration/lerna-and-nx', + '/cypress/v10-migration-guide': '/cypress/v11-migration-guide', }; /** diff --git a/packages/cypress/generators.json b/packages/cypress/generators.json index 5902855dd7a43..e6fb81b48143c 100644 --- a/packages/cypress/generators.json +++ b/packages/cypress/generators.json @@ -19,10 +19,10 @@ "schema": "./src/generators/cypress-component-project/schema.json", "description": "Set up Cypress Component Test for a project" }, - "migrate-to-cypress-10": { - "factory": "./src/generators/migrate-to-cypress-ten/migrate-to-cypress-ten#migrateCypressProject", - "schema": "./src/generators/migrate-to-cypress-ten/schema.json", - "description": "Migrate existing Cypress e2e projects to Cypress v10" + "migrate-to-cypress-11": { + "factory": "./src/generators/migrate-to-cypress-11/migrate-to-cypress-11#migrateCypressProject", + "schema": "./src/generators/migrate-to-cypress-11/schema.json", + "description": "Migrate existing Cypress e2e projects to Cypress v11" } }, "generators": { @@ -45,11 +45,10 @@ "description": "Set up Cypress Component Test for a project", "hidden": true }, - "migrate-to-cypress-10": { - "factory": "./src/generators/migrate-to-cypress-ten/migrate-to-cypress-ten#migrateCypressProject", - "schema": "./src/generators/migrate-to-cypress-ten/schema.json", - "description": "Migrate existing Cypress e2e projects to Cypress v10", - "hidden": true + "migrate-to-cypress-11": { + "factory": "./src/generators/migrate-to-cypress-11/migrate-to-cypress-11#migrateCypressProject", + "schema": "./src/generators/migrate-to-cypress-11/schema.json", + "description": "Migrate existing Cypress e2e projects to Cypress v11" } } } diff --git a/packages/cypress/index.ts b/packages/cypress/index.ts index 2c001db061b90..a522aace026c9 100644 --- a/packages/cypress/index.ts +++ b/packages/cypress/index.ts @@ -2,4 +2,4 @@ export { cypressProjectGenerator } from './src/generators/cypress-project/cypres export { cypressInitGenerator } from './src/generators/init/init'; export { conversionGenerator } from './src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint'; export { cypressComponentProject } from './src/generators/cypress-component-project/cypress-component-project'; -export { migrateCypressProject } from './src/generators/migrate-to-cypress-ten/migrate-to-cypress-ten'; +export { migrateCypressProject } from './src/generators/migrate-to-cypress-11/migrate-to-cypress-11'; diff --git a/packages/cypress/src/generators/migrate-to-cypress-ten/__snapshots__/migrate-to-cypress-ten.spec.ts.snap b/packages/cypress/src/generators/migrate-to-cypress-11/__snapshots__/migrate-to-cypress-11.spec.ts.snap similarity index 100% rename from packages/cypress/src/generators/migrate-to-cypress-ten/__snapshots__/migrate-to-cypress-ten.spec.ts.snap rename to packages/cypress/src/generators/migrate-to-cypress-11/__snapshots__/migrate-to-cypress-11.spec.ts.snap diff --git a/packages/cypress/src/generators/migrate-to-cypress-ten/conversion.util.ts b/packages/cypress/src/generators/migrate-to-cypress-11/conversion.util.ts similarity index 100% rename from packages/cypress/src/generators/migrate-to-cypress-ten/conversion.util.ts rename to packages/cypress/src/generators/migrate-to-cypress-11/conversion.util.ts diff --git a/packages/cypress/src/generators/migrate-to-cypress-ten/migrate-to-cypress-ten.spec.ts b/packages/cypress/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.spec.ts similarity index 99% rename from packages/cypress/src/generators/migrate-to-cypress-ten/migrate-to-cypress-ten.spec.ts rename to packages/cypress/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.spec.ts index 75b098c65a296..d3bf69dde8977 100644 --- a/packages/cypress/src/generators/migrate-to-cypress-ten/migrate-to-cypress-ten.spec.ts +++ b/packages/cypress/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.spec.ts @@ -16,7 +16,7 @@ import { updatePluginFile, updateProjectPaths, } from './conversion.util'; -import { migrateCypressProject } from './migrate-to-cypress-ten'; +import { migrateCypressProject } from './migrate-to-cypress-11'; jest.mock('../../utils/cypress-version'); diff --git a/packages/cypress/src/generators/migrate-to-cypress-ten/migrate-to-cypress-ten.ts b/packages/cypress/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.ts similarity index 94% rename from packages/cypress/src/generators/migrate-to-cypress-ten/migrate-to-cypress-ten.ts rename to packages/cypress/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.ts index d5f50d389724d..a29b8bb0af2a5 100644 --- a/packages/cypress/src/generators/migrate-to-cypress-ten/migrate-to-cypress-ten.ts +++ b/packages/cypress/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.ts @@ -1,10 +1,12 @@ -import { assertMinimumCypressVersion } from '@nrwl/cypress/src/utils/cypress-version'; +import { + assertMinimumCypressVersion, + installedCypressVersion, +} from '@nrwl/cypress/src/utils/cypress-version'; import { formatFiles, installPackagesTask, joinPathFragments, logger, - ProjectConfiguration, readProjectConfiguration, stripIndents, Tree, @@ -25,6 +27,10 @@ import { export async function migrateCypressProject(tree: Tree) { assertMinimumCypressVersion(8); + if (installedCypressVersion() >= 10) { + logger.info('NX This workspace is already using Cypress v10+'); + return; + } // keep history of cypress configs as some workspaces share configs // if we don't have the already migrated configs // it prevents us from being able to rename files for those projects diff --git a/packages/cypress/src/generators/migrate-to-cypress-ten/schema.json b/packages/cypress/src/generators/migrate-to-cypress-11/schema.json similarity index 62% rename from packages/cypress/src/generators/migrate-to-cypress-ten/schema.json rename to packages/cypress/src/generators/migrate-to-cypress-11/schema.json index 8d2d44c4b280f..1deb2362101d6 100644 --- a/packages/cypress/src/generators/migrate-to-cypress-ten/schema.json +++ b/packages/cypress/src/generators/migrate-to-cypress-11/schema.json @@ -1,14 +1,14 @@ { "$schema": "http://json-schema.org/schema", - "$id": "NxCypressMigrateToTen", + "$id": "NxCypressMigrateTo11", "cli": "nx", - "title": "Migrate e2e project to Cypress 10", - "description": "Migrate Cypress e2e project from v8/v9 to Cypress v10.", + "title": "Migrate e2e project to Cypress 11", + "description": "Migrate Cypress e2e project from v8/v9 to Cypress v11.", "type": "object", "examples": [ { - "command": "nx g @nrwl/cypress:migrate-to-cypress-10", - "description": "Migrate existing cypress projects to Cypress v10" + "command": "nx g @nrwl/cypress:migrate-to-cypress-11", + "description": "Migrate existing cypress projects to Cypress v11" } ], "properties": {}