Skip to content

Commit 43a7d77

Browse files
authoredApr 27, 2023
cleanup(testing): rename cypress-component-project to cypress-component-configuration (#16382)
1 parent f91920d commit 43a7d77

25 files changed

+100
-56
lines changed
 

‎docs/generated/manifests/menus.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -4203,9 +4203,9 @@
42034203
"disableCollapsible": false
42044204
},
42054205
{
4206-
"id": "cypress-component-project",
4207-
"path": "/packages/cypress/generators/cypress-component-project",
4208-
"name": "cypress-component-project",
4206+
"id": "cypress-component-configuration",
4207+
"path": "/packages/cypress/generators/cypress-component-configuration",
4208+
"name": "cypress-component-configuration",
42094209
"children": [],
42104210
"isExternal": false,
42114211
"disableCollapsible": false

‎docs/generated/manifests/packages.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -474,13 +474,13 @@
474474
"path": "/packages/cypress/generators/cypress-e2e-configuration",
475475
"type": "generator"
476476
},
477-
"/packages/cypress/generators/cypress-component-project": {
477+
"/packages/cypress/generators/cypress-component-configuration": {
478478
"description": "Set up Cypress Component Test for a project",
479-
"file": "generated/packages/cypress/generators/cypress-component-project.json",
479+
"file": "generated/packages/cypress/generators/cypress-component-configuration.json",
480480
"hidden": true,
481-
"name": "cypress-component-project",
482-
"originalFilePath": "/packages/cypress/src/generators/cypress-component-project/schema.json",
483-
"path": "/packages/cypress/generators/cypress-component-project",
481+
"name": "cypress-component-configuration",
482+
"originalFilePath": "/packages/cypress/src/generators/cypress-component-configuration/schema.json",
483+
"path": "/packages/cypress/generators/cypress-component-configuration",
484484
"type": "generator"
485485
},
486486
"/packages/cypress/generators/migrate-to-cypress-11": {

‎docs/generated/packages-metadata.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -468,11 +468,11 @@
468468
},
469469
{
470470
"description": "Set up Cypress Component Test for a project",
471-
"file": "generated/packages/cypress/generators/cypress-component-project.json",
471+
"file": "generated/packages/cypress/generators/cypress-component-configuration.json",
472472
"hidden": true,
473-
"name": "cypress-component-project",
474-
"originalFilePath": "/packages/cypress/src/generators/cypress-component-project/schema.json",
475-
"path": "cypress/generators/cypress-component-project",
473+
"name": "cypress-component-configuration",
474+
"originalFilePath": "/packages/cypress/src/generators/cypress-component-configuration/schema.json",
475+
"path": "cypress/generators/cypress-component-configuration",
476476
"type": "generator"
477477
},
478478
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "cypress-component-configuration",
3+
"factory": "./src/generators/cypress-component-configuration/cypress-component-configuration#cypressComponentConfiguration",
4+
"schema": {
5+
"$schema": "http://json-schema.org/schema",
6+
"$id": "NxCypressComponentConfiguration",
7+
"cli": "nx",
8+
"title": "Set up Cypress component testing for a project",
9+
"description": "Set up Cypress component test for a project.",
10+
"type": "object",
11+
"examples": [
12+
{
13+
"command": "nx g @nrwl/cypress:cypress-component-configuration --project=my-cool-lib ",
14+
"description": "Add cypress component testing to an existing project named my-cool-lib"
15+
}
16+
],
17+
"properties": {
18+
"project": {
19+
"type": "string",
20+
"description": "The name of the project to add cypress component testing to",
21+
"$default": { "$source": "projectName" },
22+
"x-prompt": "What project should we add Cypress component testing to?"
23+
},
24+
"bundler": {
25+
"description": "The Cypress bundler to use.",
26+
"type": "string",
27+
"enum": ["vite", "webpack"],
28+
"x-prompt": "Which Cypress bundler do you want to use for the dev-server?",
29+
"default": "webpack"
30+
}
31+
},
32+
"required": ["project"],
33+
"examplesFile": "This is a framework-agnostic generator for adding component testing to a project.\n\n```bash\nnx g cypress-component-configuration --project=my-cool-project\n```\n\nRunning this generator, adds the required files to the specified project without any configurations for Cypress. It's best to use the framework specific generator, instead `cypress-component-configuration` directly\n\n- [React component testing](/packages/react/generators/cypress-component-configuration)\n- [Angular component testing](/packages/angular/generators/cypress-component-configuration)\n\nA new `component-test` target will be added to the specified project.\n\n```bash\nnx g component-test my-cool-project\n```\n\nRead more about [Cypress Component Testing](/cypress/cypress-component-testing)\n",
34+
"presets": []
35+
},
36+
"description": "Set up Cypress Component Test for a project",
37+
"hidden": true,
38+
"implementation": "/packages/cypress/src/generators/cypress-component-configuration/cypress-component-configuration#cypressComponentConfiguration.ts",
39+
"aliases": [],
40+
"path": "/packages/cypress/src/generators/cypress-component-configuration/schema.json",
41+
"type": "generator"
42+
}

‎docs/generated/packages/react/generators/cypress-component-configuration.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
}
5454
},
5555
"required": ["project"],
56-
"examplesFile": "{% callout type=\"caution\" title=\"Can I use component testing?\" %}\nReact component testing with Nx requires **Cypress version 10.7.0** and up.\n\nYou can migrate with to v10 via the [migrate-to-cypress-10 generator](/packages/cypress/generators/migrate-to-cypress-10).\n\nThis generator is for Cypress based component testing.\n\nIf you want to test components via Storybook with Cypress, then check out the [storybook-configuration generator docs](/packages/react/generators/storybook-configuration)\n{% /callout %}\n\nThis generator is designed to get your React project up and running with Cypress Component Testing.\n\n```shell\nnx g @nrwl/react:cypress-component-project --project=my-cool-react-project\n```\n\nRunning this generator, adds the required files to the specified project with a preconfigured `cypress.config.ts` designed for Nx workspaces.\n\nThe following file will be added to projects where the Component Testing build target is using `webpack` for bundling:\n\n```ts {% fileName=\"cypress.config.ts\" %}\nimport { defineConfig } from 'cypress';\nimport { nxComponentTestingPreset } from '@nrwl/react/plugins/component-testing';\n\nexport default defineConfig({\n component: nxComponentTestingPreset(__filename, {\n bundler: 'webpack',\n }),\n});\n```\n\nThe following file will be added to projects where the Component Testing build target is using `vite` for bundling:\n\n```ts {% fileName=\"cypress.config.ts\" %}\nimport { defineConfig } from 'cypress';\nimport { nxComponentTestingPreset } from '@nrwl/react/plugins/component-testing';\n\nexport default defineConfig({\n component: nxComponentTestingPreset(__filename, {\n bundler: 'vite',\n }),\n});\n```\n\nHere is an example on how to add custom options to the configuration\n\n```ts {% fileName=\"cypress.config.ts\" %}\nimport { defineConfig } from 'cypress';\nimport { nxComponentTestingPreset } from '@nrwl/react/plugins/component-testing';\n\nexport default defineConfig({\n component: {\n ...nxComponentTestingPreset(__filename, {\n bundler: 'webpack',\n }),\n // extra options here\n },\n});\n```\n\n## The `bundler` option\n\nComponent testing supports two different bundlers: `webpack` and `vite`. The Nx generator will pick up the bundler used in the specified project's build target. If the build target is using `@nrwl/webpack:webpack`, then the generator will use `webpack` as the bundler. If the build target is using `@nrwl/vite:build`, then the generator will use `vite` as the bundler.\n\nYou can manually set the bundler by passing `--bundler=webpack` or `--bundler=vite` to the generator, but that is not needed since the generator will pick up the correct bundler for you. However, if you want to use a different bundler than the one that is used in the build target, then you can manually set it using that flag.\n\n## Specifying a Build Target\n\nComponent testing requires a _build target_ to correctly run the component test dev server. This option can be manually specified with `--build-target=some-react-app:build`, but Nx will infer this usage from the [project graph](/concepts/mental-model#the-project-graph) if one isn't provided.\n\nFor React projects, the build target needs to be using the `@nrwl/webpack:webpack` executor.\nThe generator will throw an error if a build target can't be found and suggest passing one in manually.\n\nLetting Nx infer the build target by default\n\n```shell\nnx g @nrwl/react:cypress-component-project --project=my-cool-react-project\n```\n\nManually specifying the build target\n\n```shell\nnx g @nrwl/react:cypress-component-project --project=my-cool-react-project --build-target:some-react-app:build --generate-tests\n```\n\n{% callout type=\"note\" title=\"Build Target with Configuration\" %}\nIf you're wanting to use a build target with a specific configuration. i.e. `my-app:build:production`,\nthen manually providing `--build-target=my-app:build:production` is the best way to do that.\n{% /callout %}\n\n## Auto Generating Tests\n\nYou can optionally use the `--generate-tests` flag to generate a test file for each component in your project.\n\n```shell\nnx g @nrwl/react:cypress-component-project --project=my-cool-react-project --generate-tests\n```\n\n## Running Component Tests\n\nA new `component-test` target will be added to the specified project to run your component tests.\n\n```shell\nnx g component-test my-cool-react-project\n```\n\nHere is an example of the project configuration that is generated. The `--build-target` option is added as the `devServerTarget` which can be changed as needed.\n\n```json {% fileName=\"project.json\" %}\n{\n \"targets\" {\n \"component-test\": {\n \"executor\": \"@nrwl/cypress:cypress\",\n \"options\": {\n \"cypressConfig\": \"<path-to-project-root>/cypress.config.ts\",\n \"testingType\": \"component\",\n \"devServerTarget\": \"some-react-app:build\",\n \"skipServe\": true\n }\n }\n }\n}\n```\n\nNx also supports [Angular component testing](/packages/angular/generators/cypress-component-configuration).\n",
56+
"examplesFile": "{% callout type=\"caution\" title=\"Can I use component testing?\" %}\nReact component testing with Nx requires **Cypress version 10.7.0** and up.\n\nYou can migrate with to v10 via the [migrate-to-cypress-10 generator](/packages/cypress/generators/migrate-to-cypress-10).\n\nThis generator is for Cypress based component testing.\n\nIf you want to test components via Storybook with Cypress, then check out the [storybook-configuration generator docs](/packages/react/generators/storybook-configuration)\n{% /callout %}\n\nThis generator is designed to get your React project up and running with Cypress Component Testing.\n\n```shell\nnx g @nrwl/react:cypress-component-configuration --project=my-cool-react-project\n```\n\nRunning this generator, adds the required files to the specified project with a preconfigured `cypress.config.ts` designed for Nx workspaces.\n\nThe following file will be added to projects where the Component Testing build target is using `webpack` for bundling:\n\n```ts {% fileName=\"cypress.config.ts\" %}\nimport { defineConfig } from 'cypress';\nimport { nxComponentTestingPreset } from '@nrwl/react/plugins/component-testing';\n\nexport default defineConfig({\n component: nxComponentTestingPreset(__filename, {\n bundler: 'webpack',\n }),\n});\n```\n\nThe following file will be added to projects where the Component Testing build target is using `vite` for bundling:\n\n```ts {% fileName=\"cypress.config.ts\" %}\nimport { defineConfig } from 'cypress';\nimport { nxComponentTestingPreset } from '@nrwl/react/plugins/component-testing';\n\nexport default defineConfig({\n component: nxComponentTestingPreset(__filename, {\n bundler: 'vite',\n }),\n});\n```\n\nHere is an example on how to add custom options to the configuration\n\n```ts {% fileName=\"cypress.config.ts\" %}\nimport { defineConfig } from 'cypress';\nimport { nxComponentTestingPreset } from '@nrwl/react/plugins/component-testing';\n\nexport default defineConfig({\n component: {\n ...nxComponentTestingPreset(__filename, {\n bundler: 'webpack',\n }),\n // extra options here\n },\n});\n```\n\n## The `bundler` option\n\nComponent testing supports two different bundlers: `webpack` and `vite`. The Nx generator will pick up the bundler used in the specified project's build target. If the build target is using `@nrwl/webpack:webpack`, then the generator will use `webpack` as the bundler. If the build target is using `@nrwl/vite:build`, then the generator will use `vite` as the bundler.\n\nYou can manually set the bundler by passing `--bundler=webpack` or `--bundler=vite` to the generator, but that is not needed since the generator will pick up the correct bundler for you. However, if you want to use a different bundler than the one that is used in the build target, then you can manually set it using that flag.\n\n## Specifying a Build Target\n\nComponent testing requires a _build target_ to correctly run the component test dev server. This option can be manually specified with `--build-target=some-react-app:build`, but Nx will infer this usage from the [project graph](/concepts/mental-model#the-project-graph) if one isn't provided.\n\nFor React projects, the build target needs to be using the `@nrwl/webpack:webpack` executor.\nThe generator will throw an error if a build target can't be found and suggest passing one in manually.\n\nLetting Nx infer the build target by default\n\n```shell\nnx g @nrwl/react:cypress-component-configuration --project=my-cool-react-project\n```\n\nManually specifying the build target\n\n```shell\nnx g @nrwl/react:cypress-component-configuration --project=my-cool-react-project --build-target:some-react-app:build --generate-tests\n```\n\n{% callout type=\"note\" title=\"Build Target with Configuration\" %}\nIf you're wanting to use a build target with a specific configuration. i.e. `my-app:build:production`,\nthen manually providing `--build-target=my-app:build:production` is the best way to do that.\n{% /callout %}\n\n## Auto Generating Tests\n\nYou can optionally use the `--generate-tests` flag to generate a test file for each component in your project.\n\n```shell\nnx g @nrwl/react:cypress-component-configuration --project=my-cool-react-project --generate-tests\n```\n\n## Running Component Tests\n\nA new `component-test` target will be added to the specified project to run your component tests.\n\n```shell\nnx g component-test my-cool-react-project\n```\n\nHere is an example of the project configuration that is generated. The `--build-target` option is added as the `devServerTarget` which can be changed as needed.\n\n```json {% fileName=\"project.json\" %}\n{\n \"targets\" {\n \"component-test\": {\n \"executor\": \"@nrwl/cypress:cypress\",\n \"options\": {\n \"cypressConfig\": \"<path-to-project-root>/cypress.config.ts\",\n \"testingType\": \"component\",\n \"devServerTarget\": \"some-react-app:build\",\n \"skipServe\": true\n }\n }\n }\n}\n```\n\nNx also supports [Angular component testing](/packages/angular/generators/cypress-component-configuration).\n",
5757
"presets": []
5858
},
5959
"description": "Setup Cypress component testing for a React project",

‎packages/angular/src/generators/cypress-component-configuration/cypress-component-configuration.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { cypressComponentProject } from '@nx/cypress';
1+
import { cypressComponentConfiguration as baseCyCTConfig } from '@nx/cypress';
22
import { findBuildConfig } from '@nx/cypress/src/utils/find-target-options';
33
import {
44
formatFiles,
@@ -28,7 +28,7 @@ export async function cypressComponentConfiguration(
2828
options: CypressComponentConfigSchema
2929
) {
3030
const projectConfig = readProjectConfiguration(tree, options.project);
31-
const installTask = await cypressComponentProject(tree, {
31+
const installTask = await baseCyCTConfig(tree, {
3232
project: options.project,
3333
skipFormat: true,
3434
});

‎packages/cypress/docs/cypress-component-project-examples.md ‎packages/cypress/docs/cypress-component-configuration-examples.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
This is a framework-agnostic generator for adding component testing to a project.
22

33
```bash
4-
nx g cypress-component-project --project=my-cool-project
4+
nx g cypress-component-configuration --project=my-cool-project
55
```
66

7-
Running this generator, adds the required files to the specified project without any configurations for Cypress. It's best to use the framework specific generator, instead `cypress-component-project` directly
7+
Running this generator, adds the required files to the specified project without any configurations for Cypress. It's best to use the framework specific generator, instead `cypress-component-configuration` directly
88

99
- [React component testing](/packages/react/generators/cypress-component-configuration)
1010
- [Angular component testing](/packages/angular/generators/cypress-component-configuration)

‎packages/cypress/generators.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
"schema": "./src/generators/cypress-e2e-configuration/schema.json",
2121
"description": "Add a Cypress E2E Configuration to an existing project."
2222
},
23-
"cypress-component-project": {
24-
"factory": "./src/generators/cypress-component-project/cypress-component-project#cypressComponentProject",
25-
"schema": "./src/generators/cypress-component-project/schema.json",
23+
"cypress-component-configuration": {
24+
"factory": "./src/generators/cypress-component-configuration/cypress-component-configuration#cypressComponentConfiguration",
25+
"schema": "./src/generators/cypress-component-configuration/schema.json",
2626
"description": "Set up Cypress Component Test for a project"
2727
},
2828
"migrate-to-cypress-11": {
@@ -51,9 +51,9 @@
5151
"schema": "./src/generators/cypress-e2e-configuration/schema.json",
5252
"description": "Add a Cypress E2E Configuration to an existing project."
5353
},
54-
"cypress-component-project": {
55-
"factory": "./src/generators/cypress-component-project/cypress-component-project#cypressComponentProject",
56-
"schema": "./src/generators/cypress-component-project/schema.json",
54+
"cypress-component-configuration": {
55+
"factory": "./src/generators/cypress-component-configuration/cypress-component-configuration#cypressComponentConfiguration",
56+
"schema": "./src/generators/cypress-component-configuration/schema.json",
5757
"description": "Set up Cypress Component Test for a project",
5858
"hidden": true
5959
},

‎packages/cypress/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export { cypressProjectGenerator } from './src/generators/cypress-project/cypress-project';
22
export { cypressInitGenerator } from './src/generators/init/init';
33
export { conversionGenerator } from './src/generators/convert-tslint-to-eslint/convert-tslint-to-eslint';
4-
export { cypressComponentProject } from './src/generators/cypress-component-project/cypress-component-project';
4+
export { cypressComponentConfiguration } from './src/generators/cypress-component-configuration/cypress-component-configuration';
55
export { migrateCypressProject } from './src/generators/migrate-to-cypress-11/migrate-to-cypress-11';
66
export { cypressE2EConfigurationGenerator } from './src/generators/cypress-e2e-configuration/cypress-e2e-configuration';

‎packages/cypress/src/generators/cypress-component-project/__snapshots__/cypress-component-project.spec.ts.snap ‎packages/cypress/src/generators/cypress-component-configuration/__snapshots__/cypress-component-configuration.spec.ts.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`Cypress Component Project should add base cypress component testing config 1`] = `
3+
exports[`Cypress Component Configuration should add base cypress component testing config 1`] = `
44
{
55
"executor": "@nx/cypress:cypress",
66
"options": {
@@ -10,7 +10,7 @@ exports[`Cypress Component Project should add base cypress component testing con
1010
}
1111
`;
1212

13-
exports[`Cypress Component Project should not error when rerunning on an existing project 1`] = `
13+
exports[`Cypress Component Configuration should not error when rerunning on an existing project 1`] = `
1414
{
1515
"executor": "@nx/cypress:cypress",
1616
"options": {

‎packages/cypress/src/generators/cypress-component-project/cypress-component-project.spec.ts ‎packages/cypress/src/generators/cypress-component-configuration/cypress-component-configuration.spec.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
} from '@nx/devkit';
1010
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
1111
import { installedCypressVersion } from '../../utils/cypress-version';
12-
import { cypressComponentProject } from './cypress-component-project';
12+
import { cypressComponentConfiguration } from './cypress-component-configuration';
1313

1414
jest.mock('../../utils/cypress-version');
1515
let projectConfig: ProjectConfiguration = {
@@ -31,7 +31,7 @@ let projectConfig: ProjectConfiguration = {
3131
},
3232
},
3333
};
34-
describe('Cypress Component Project', () => {
34+
describe('Cypress Component Configuration', () => {
3535
let tree: Tree;
3636
let mockedInstalledCypressVersion: jest.Mock<
3737
ReturnType<typeof installedCypressVersion>
@@ -97,7 +97,7 @@ describe('Cypress Component Project', () => {
9797

9898
it('should add base cypress component testing config', async () => {
9999
mockedInstalledCypressVersion.mockReturnValue(10);
100-
await cypressComponentProject(tree, {
100+
await cypressComponentConfiguration(tree, {
101101
project: 'cool-lib',
102102
skipFormat: false,
103103
});
@@ -156,7 +156,7 @@ describe('Cypress Component Project', () => {
156156
};
157157
return json;
158158
});
159-
await cypressComponentProject(tree, {
159+
await cypressComponentConfiguration(tree, {
160160
project: 'cool-lib',
161161
skipFormat: false,
162162
});
@@ -196,7 +196,7 @@ describe('Cypress Component Project', () => {
196196
},
197197
});
198198

199-
await cypressComponentProject(tree, {
199+
await cypressComponentConfiguration(tree, {
200200
project: 'cool-lib',
201201
skipFormat: true,
202202
});
@@ -212,7 +212,7 @@ describe('Cypress Component Project', () => {
212212
mockedInstalledCypressVersion.mockReturnValue(9);
213213
await expect(
214214
async () =>
215-
await cypressComponentProject(tree, {
215+
await cypressComponentConfiguration(tree, {
216216
project: 'cool-lib',
217217
skipFormat: true,
218218
})

‎packages/cypress/src/generators/cypress-component-project/cypress-component-project.ts ‎packages/cypress/src/generators/cypress-component-configuration/cypress-component-configuration.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import {
2020
cypressWebpackVersion,
2121
htmlWebpackPluginVersion,
2222
} from '../../utils/versions';
23-
import { CypressComponentProjectSchema } from './schema';
23+
import { CypressComponentConfigurationSchema } from './schema';
2424

25-
export async function cypressComponentProject(
25+
export async function cypressComponentConfiguration(
2626
tree: Tree,
27-
options: CypressComponentProjectSchema
27+
options: CypressComponentConfigurationSchema
2828
) {
2929
const cyVersion = installedCypressVersion();
3030
if (cyVersion && cyVersion < 10) {
@@ -50,7 +50,7 @@ export async function cypressComponentProject(
5050
};
5151
}
5252

53-
function updateDeps(tree: Tree, options: CypressComponentProjectSchema) {
53+
function updateDeps(tree: Tree, options: CypressComponentConfigurationSchema) {
5454
const devDeps = {
5555
cypress: cypressVersion,
5656
};
@@ -68,7 +68,7 @@ function updateDeps(tree: Tree, options: CypressComponentProjectSchema) {
6868
function addProjectFiles(
6969
tree: Tree,
7070
projectConfig: ProjectConfiguration,
71-
options: CypressComponentProjectSchema
71+
options: CypressComponentConfigurationSchema
7272
) {
7373
generateFiles(
7474
tree,
@@ -86,7 +86,7 @@ function addProjectFiles(
8686
function addTargetToProject(
8787
tree: Tree,
8888
projectConfig: ProjectConfiguration,
89-
options: CypressComponentProjectSchema
89+
options: CypressComponentConfigurationSchema
9090
) {
9191
projectConfig.targets['component-test'] = {
9292
executor: '@nx/cypress:cypress',

‎packages/cypress/src/generators/cypress-component-project/schema.d.ts ‎packages/cypress/src/generators/cypress-component-configuration/schema.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export interface CypressComponentProjectSchema {
1+
export interface CypressComponentConfigurationSchema {
22
project: string;
33
skipFormat: boolean;
44
bundler?: 'webpack' | 'vite';

‎packages/cypress/src/generators/cypress-component-project/schema.json ‎packages/cypress/src/generators/cypress-component-configuration/schema.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"$schema": "http://json-schema.org/schema",
3-
"$id": "NxCypressComponentProject",
3+
"$id": "NxCypressComponentConfiguration",
44
"cli": "nx",
55
"title": "Set up Cypress component testing for a project",
66
"description": "Set up Cypress component test for a project.",
77
"type": "object",
88
"examples": [
99
{
10-
"command": "nx g @nrwl/cypress:cypress-component-project --project=my-cool-lib ",
10+
"command": "nx g @nrwl/cypress:cypress-component-configuration --project=my-cool-lib ",
1111
"description": "Add cypress component testing to an existing project named my-cool-lib"
1212
}
1313
],
@@ -29,5 +29,5 @@
2929
}
3030
},
3131
"required": ["project"],
32-
"examplesFile": "../../../docs/cypress-component-project-examples.md"
32+
"examplesFile": "../../../docs/cypress-component-configuration-examples.md"
3333
}

‎packages/cypress/src/migrations/update-15-0-0/update-cy-mount-usage.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
updateCyMountUsage,
1212
} from './update-cy-mount-usage';
1313
import { libraryGenerator } from '@nx/js';
14-
import { cypressComponentProject } from '../../generators/cypress-component-project/cypress-component-project';
14+
import { cypressComponentConfiguration } from '../../generators/cypress-component-configuration/cypress-component-configuration';
1515

1616
jest.mock('../../utils/cypress-version');
1717
// nested code imports graph from the repo, which might have innacurate graph version
@@ -179,11 +179,11 @@ Cypress.Commands.add('login', (email, password) => {
179179
async function setup(tree: Tree) {
180180
await libraryGenerator(tree, { name: 'my-lib' });
181181
await libraryGenerator(tree, { name: 'another-lib' });
182-
await cypressComponentProject(tree, {
182+
await cypressComponentConfiguration(tree, {
183183
project: 'my-lib',
184184
skipFormat: false,
185185
});
186-
await cypressComponentProject(tree, {
186+
await cypressComponentConfiguration(tree, {
187187
project: 'another-lib',
188188
skipFormat: false,
189189
});

‎packages/cypress/src/migrations/update-15-1-0/cypress-11.spec.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
99
import updateToCypress11 from './cypress-11';
1010
import { installedCypressVersion } from '../../utils/cypress-version';
1111
jest.mock('../../utils/cypress-version');
12-
import { cypressComponentProject } from '../../generators/cypress-component-project/cypress-component-project';
12+
import { cypressComponentConfiguration } from '../../generators/cypress-component-configuration/cypress-component-configuration';
1313

1414
describe('Cypress 11 Migration', () => {
1515
let tree: Tree;
@@ -119,7 +119,7 @@ async function setup(tree: Tree) {
119119
await libraryGenerator(tree, {
120120
name: 'my-react-lib',
121121
});
122-
await cypressComponentProject(tree, {
122+
await cypressComponentConfiguration(tree, {
123123
project: 'my-react-lib',
124124
skipFormat: true,
125125
});
@@ -266,7 +266,7 @@ describe('again', () => {
266266
name: 'my-ng-lib',
267267
});
268268

269-
await cypressComponentProject(tree, {
269+
await cypressComponentConfiguration(tree, {
270270
project: 'my-ng-lib',
271271
skipFormat: true,
272272
});

‎packages/next/src/generators/cypress-component-configuration/cypress-component-configuration.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ export async function cypressComponentConfiguration(
2323
) {
2424
const tasks: GeneratorCallback[] = [];
2525

26-
const { cypressComponentProject } = ensurePackage<
26+
const { cypressComponentConfiguration } = ensurePackage<
2727
typeof import('@nx/cypress')
2828
>('@nx/cypress', nxVersion);
2929
tasks.push(
30-
await cypressComponentProject(tree, {
30+
await cypressComponentConfiguration(tree, {
3131
project: options.project,
3232
skipFormat: true,
3333
})

‎packages/react/docs/cypress-component-configuration-examples.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ If you want to test components via Storybook with Cypress, then check out the [s
1111
This generator is designed to get your React project up and running with Cypress Component Testing.
1212

1313
```shell
14-
nx g @nrwl/react:cypress-component-project --project=my-cool-react-project
14+
nx g @nrwl/react:cypress-component-configuration --project=my-cool-react-project
1515
```
1616

1717
Running this generator, adds the required files to the specified project with a preconfigured `cypress.config.ts` designed for Nx workspaces.
@@ -74,13 +74,13 @@ The generator will throw an error if a build target can't be found and suggest p
7474
Letting Nx infer the build target by default
7575

7676
```shell
77-
nx g @nrwl/react:cypress-component-project --project=my-cool-react-project
77+
nx g @nrwl/react:cypress-component-configuration --project=my-cool-react-project
7878
```
7979

8080
Manually specifying the build target
8181

8282
```shell
83-
nx g @nrwl/react:cypress-component-project --project=my-cool-react-project --build-target:some-react-app:build --generate-tests
83+
nx g @nrwl/react:cypress-component-configuration --project=my-cool-react-project --build-target:some-react-app:build --generate-tests
8484
```
8585

8686
{% callout type="note" title="Build Target with Configuration" %}
@@ -93,7 +93,7 @@ then manually providing `--build-target=my-app:build:production` is the best way
9393
You can optionally use the `--generate-tests` flag to generate a test file for each component in your project.
9494

9595
```shell
96-
nx g @nrwl/react:cypress-component-project --project=my-cool-react-project --generate-tests
96+
nx g @nrwl/react:cypress-component-configuration --project=my-cool-react-project --generate-tests
9797
```
9898

9999
## Running Component Tests

‎packages/react/src/generators/cypress-component-configuration/cypress-component-configuration.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ export async function cypressComponentConfigGenerator(
1818
tree: Tree,
1919
options: CypressComponentConfigurationSchema
2020
) {
21-
const { cypressComponentProject } = ensurePackage('@nx/cypress', nxVersion);
21+
const { cypressComponentConfiguration: baseCyCtConfig } = ensurePackage<
22+
typeof import('@nx/cypress')
23+
>('@nx/cypress', nxVersion);
2224
const projectConfig = readProjectConfiguration(tree, options.project);
23-
const installTask = await cypressComponentProject(tree, {
25+
const installTask = await baseCyCtConfig(tree, {
2426
project: options.project,
2527
skipFormat: true,
2628
});

1 commit comments

Comments
 (1)

vercel[bot] commented on Apr 27, 2023

@vercel[bot]

Successfully deployed to the following URLs:

nx-dev – ./

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

Please sign in to comment.