Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cleanup(testing): rename cypress-component-project to cypress-component-configuration #16382

Merged
merged 1 commit into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/generated/manifests/menus.json
Original file line number Diff line number Diff line change
Expand Up @@ -4203,9 +4203,9 @@
"disableCollapsible": false
},
{
"id": "cypress-component-project",
"path": "/packages/cypress/generators/cypress-component-project",
"name": "cypress-component-project",
"id": "cypress-component-configuration",
"path": "/packages/cypress/generators/cypress-component-configuration",
"name": "cypress-component-configuration",
"children": [],
"isExternal": false,
"disableCollapsible": false
Expand Down
10 changes: 5 additions & 5 deletions docs/generated/manifests/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -474,13 +474,13 @@
"path": "/packages/cypress/generators/cypress-e2e-configuration",
"type": "generator"
},
"/packages/cypress/generators/cypress-component-project": {
"/packages/cypress/generators/cypress-component-configuration": {
"description": "Set up Cypress Component Test for a project",
"file": "generated/packages/cypress/generators/cypress-component-project.json",
"file": "generated/packages/cypress/generators/cypress-component-configuration.json",
"hidden": true,
"name": "cypress-component-project",
"originalFilePath": "/packages/cypress/src/generators/cypress-component-project/schema.json",
"path": "/packages/cypress/generators/cypress-component-project",
"name": "cypress-component-configuration",
"originalFilePath": "/packages/cypress/src/generators/cypress-component-configuration/schema.json",
"path": "/packages/cypress/generators/cypress-component-configuration",
"type": "generator"
},
"/packages/cypress/generators/migrate-to-cypress-11": {
Expand Down
8 changes: 4 additions & 4 deletions docs/generated/packages-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,11 @@
},
{
"description": "Set up Cypress Component Test for a project",
"file": "generated/packages/cypress/generators/cypress-component-project.json",
"file": "generated/packages/cypress/generators/cypress-component-configuration.json",
"hidden": true,
"name": "cypress-component-project",
"originalFilePath": "/packages/cypress/src/generators/cypress-component-project/schema.json",
"path": "cypress/generators/cypress-component-project",
"name": "cypress-component-configuration",
"originalFilePath": "/packages/cypress/src/generators/cypress-component-configuration/schema.json",
"path": "cypress/generators/cypress-component-configuration",
"type": "generator"
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "cypress-component-configuration",
"factory": "./src/generators/cypress-component-configuration/cypress-component-configuration#cypressComponentConfiguration",
"schema": {
"$schema": "http://json-schema.org/schema",
"$id": "NxCypressComponentConfiguration",
"cli": "nx",
"title": "Set up Cypress component testing for a project",
"description": "Set up Cypress component test for a project.",
"type": "object",
"examples": [
{
"command": "nx g @nrwl/cypress:cypress-component-configuration --project=my-cool-lib ",
"description": "Add cypress component testing to an existing project named my-cool-lib"
}
],
"properties": {
"project": {
"type": "string",
"description": "The name of the project to add cypress component testing to",
"$default": { "$source": "projectName" },
"x-prompt": "What project should we add Cypress component testing to?"
},
"bundler": {
"description": "The Cypress bundler to use.",
"type": "string",
"enum": ["vite", "webpack"],
"x-prompt": "Which Cypress bundler do you want to use for the dev-server?",
"default": "webpack"
}
},
"required": ["project"],
"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",
"presets": []
},
"description": "Set up Cypress Component Test for a project",
"hidden": true,
"implementation": "/packages/cypress/src/generators/cypress-component-configuration/cypress-component-configuration#cypressComponentConfiguration.ts",
"aliases": [],
"path": "/packages/cypress/src/generators/cypress-component-configuration/schema.json",
"type": "generator"
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
}
},
"required": ["project"],
"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",
"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",
"presets": []
},
"description": "Setup Cypress component testing for a React project",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { cypressComponentProject } from '@nx/cypress';
import { cypressComponentConfiguration as baseCyCTConfig } from '@nx/cypress';
import { findBuildConfig } from '@nx/cypress/src/utils/find-target-options';
import {
formatFiles,
Expand Down Expand Up @@ -28,7 +28,7 @@ export async function cypressComponentConfiguration(
options: CypressComponentConfigSchema
) {
const projectConfig = readProjectConfiguration(tree, options.project);
const installTask = await cypressComponentProject(tree, {
const installTask = await baseCyCTConfig(tree, {
project: options.project,
skipFormat: true,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
This is a framework-agnostic generator for adding component testing to a project.

```bash
nx g cypress-component-project --project=my-cool-project
nx g cypress-component-configuration --project=my-cool-project
```

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
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

- [React component testing](/packages/react/generators/cypress-component-configuration)
- [Angular component testing](/packages/angular/generators/cypress-component-configuration)
Expand Down
12 changes: 6 additions & 6 deletions packages/cypress/generators.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"schema": "./src/generators/cypress-e2e-configuration/schema.json",
"description": "Add a Cypress E2E Configuration to an existing project."
},
"cypress-component-project": {
"factory": "./src/generators/cypress-component-project/cypress-component-project#cypressComponentProject",
"schema": "./src/generators/cypress-component-project/schema.json",
"cypress-component-configuration": {
"factory": "./src/generators/cypress-component-configuration/cypress-component-configuration#cypressComponentConfiguration",
"schema": "./src/generators/cypress-component-configuration/schema.json",
"description": "Set up Cypress Component Test for a project"
},
"migrate-to-cypress-11": {
Expand Down Expand Up @@ -51,9 +51,9 @@
"schema": "./src/generators/cypress-e2e-configuration/schema.json",
"description": "Add a Cypress E2E Configuration to an existing project."
},
"cypress-component-project": {
"factory": "./src/generators/cypress-component-project/cypress-component-project#cypressComponentProject",
"schema": "./src/generators/cypress-component-project/schema.json",
"cypress-component-configuration": {
"factory": "./src/generators/cypress-component-configuration/cypress-component-configuration#cypressComponentConfiguration",
"schema": "./src/generators/cypress-component-configuration/schema.json",
"description": "Set up Cypress Component Test for a project",
"hidden": true
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cypress/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { cypressProjectGenerator } from './src/generators/cypress-project/cypress-project';
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 { cypressComponentConfiguration } from './src/generators/cypress-component-configuration/cypress-component-configuration';
export { migrateCypressProject } from './src/generators/migrate-to-cypress-11/migrate-to-cypress-11';
export { cypressE2EConfigurationGenerator } from './src/generators/cypress-e2e-configuration/cypress-e2e-configuration';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Cypress Component Project should add base cypress component testing config 1`] = `
exports[`Cypress Component Configuration should add base cypress component testing config 1`] = `
{
"executor": "@nx/cypress:cypress",
"options": {
Expand All @@ -10,7 +10,7 @@ exports[`Cypress Component Project should add base cypress component testing con
}
`;

exports[`Cypress Component Project should not error when rerunning on an existing project 1`] = `
exports[`Cypress Component Configuration should not error when rerunning on an existing project 1`] = `
{
"executor": "@nx/cypress:cypress",
"options": {
Expand Down
Loading