Skip to content

Commit

Permalink
fix(testing): rename cy 10 migration to 11 (#13646)
Browse files Browse the repository at this point in the history
  • Loading branch information
barbados-clemens committed Dec 5, 2022
1 parent 8a74e62 commit 5d910c0
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 43 deletions.
32 changes: 16 additions & 16 deletions docs/generated/packages/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down Expand Up @@ -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": [
Expand Down
6 changes: 3 additions & 3 deletions docs/map.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion docs/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"init",
"cypress-project",
"cypress-component-project",
"migrate-to-cypress-10"
"migrate-to-cypress-11"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion docs/shared/cypress-component-testing.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
1 change: 1 addition & 0 deletions nx-dev/nx-dev/redirect-rules.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
};

/**
Expand Down
17 changes: 8 additions & 9 deletions packages/cypress/generators.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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"
}
}
}
2 changes: 1 addition & 1 deletion packages/cypress/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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": {}
Expand Down

1 comment on commit 5d910c0

@vercel
Copy link

@vercel vercel bot commented on 5d910c0 Dec 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-five.vercel.app
nx-dev-nrwl.vercel.app
nx-dev-git-master-nrwl.vercel.app
nx.dev

Please sign in to comment.