@nx/cypress 0.0.0-pr-22179-271588f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +68 -0
  3. package/executors.json +9 -0
  4. package/generators.json +37 -0
  5. package/index.d.ts +11 -0
  6. package/index.js +20 -0
  7. package/migrations.json +111 -0
  8. package/package.json +58 -0
  9. package/plugin.d.ts +1 -0
  10. package/plugin.js +6 -0
  11. package/plugins/cypress-preset.d.ts +69 -0
  12. package/plugins/cypress-preset.js +154 -0
  13. package/src/executors/cypress/cypress.impl.d.ts +40 -0
  14. package/src/executors/cypress/cypress.impl.js +182 -0
  15. package/src/executors/cypress/schema.json +186 -0
  16. package/src/generators/base-setup/base-setup.d.ts +12 -0
  17. package/src/generators/base-setup/base-setup.js +80 -0
  18. package/src/generators/base-setup/files/common/__directory__/fixtures/example.json +5 -0
  19. package/src/generators/base-setup/files/common/__directory__/support/commands.ts__ext__ +35 -0
  20. package/src/generators/base-setup/files/common/__directory__/tsconfig.json__ext__ +20 -0
  21. package/src/generators/base-setup/files/config-js-cjs/__directory__/support/commands.js__ext__ +35 -0
  22. package/src/generators/base-setup/files/config-js-cjs/cypress.config.js__ext__ +3 -0
  23. package/src/generators/base-setup/files/config-js-esm/__directory__/support/commands.js__ext__ +35 -0
  24. package/src/generators/base-setup/files/config-js-esm/cypress.config.js__ext__ +3 -0
  25. package/src/generators/base-setup/files/config-ts/__directory__/support/commands.ts__ext__ +35 -0
  26. package/src/generators/base-setup/files/config-ts/cypress.config.ts__ext__ +3 -0
  27. package/src/generators/component-configuration/component-configuration.d.ts +6 -0
  28. package/src/generators/component-configuration/component-configuration.js +165 -0
  29. package/src/generators/component-configuration/files/__directory__/support/component-index.html +16 -0
  30. package/src/generators/component-configuration/files/__directory__/support/component.ts__ext__ +27 -0
  31. package/src/generators/component-configuration/schema.d.ts +14 -0
  32. package/src/generators/component-configuration/schema.json +43 -0
  33. package/src/generators/configuration/configuration.d.ts +23 -0
  34. package/src/generators/configuration/configuration.js +220 -0
  35. package/src/generators/configuration/files/v10/__directory__/e2e/app.cy.ts__tmpl__ +13 -0
  36. package/src/generators/configuration/files/v10/__directory__/support/app.po.ts__tmpl__ +1 -0
  37. package/src/generators/configuration/files/v10/__directory__/support/e2e.ts__tmpl__ +17 -0
  38. package/src/generators/configuration/files/v9/__directory__/fixtures/example.json__tmpl__ +4 -0
  39. package/src/generators/configuration/files/v9/__directory__/integration/app.spec.ts__tmpl__ +13 -0
  40. package/src/generators/configuration/files/v9/__directory__/plugins/index.js +22 -0
  41. package/src/generators/configuration/files/v9/__directory__/support/app.po.ts__tmpl__ +1 -0
  42. package/src/generators/configuration/files/v9/__directory__/support/commands.ts__tmpl__ +33 -0
  43. package/src/generators/configuration/files/v9/__directory__/support/index.ts__tmpl__ +17 -0
  44. package/src/generators/configuration/files/v9/__directory__/tsconfig.json +10 -0
  45. package/src/generators/configuration/files/v9/cypress.json +12 -0
  46. package/src/generators/configuration/schema.json +96 -0
  47. package/src/generators/cypress-project/cypress-project.d.ts +16 -0
  48. package/src/generators/cypress-project/cypress-project.js +213 -0
  49. package/src/generators/cypress-project/files/v10-and-after/cypress.config.ts__tmpl__ +10 -0
  50. package/src/generators/cypress-project/files/v10-and-after/src/e2e/app.cy.ts__tmpl__ +13 -0
  51. package/src/generators/cypress-project/files/v10-and-after/src/fixtures/example.json__tmpl__ +4 -0
  52. package/src/generators/cypress-project/files/v10-and-after/src/support/app.po.ts__tmpl__ +1 -0
  53. package/src/generators/cypress-project/files/v10-and-after/src/support/commands.ts__tmpl__ +33 -0
  54. package/src/generators/cypress-project/files/v10-and-after/src/support/e2e.ts__tmpl__ +17 -0
  55. package/src/generators/cypress-project/files/v10-and-after/tsconfig.json +10 -0
  56. package/src/generators/cypress-project/files/v9-and-under/cypress.json +12 -0
  57. package/src/generators/cypress-project/files/v9-and-under/src/fixtures/example.json__tmpl__ +4 -0
  58. package/src/generators/cypress-project/files/v9-and-under/src/integration/app.spec.ts__tmpl__ +13 -0
  59. package/src/generators/cypress-project/files/v9-and-under/src/plugins/index.js +22 -0
  60. package/src/generators/cypress-project/files/v9-and-under/src/support/app.po.ts__tmpl__ +1 -0
  61. package/src/generators/cypress-project/files/v9-and-under/src/support/commands.ts__tmpl__ +33 -0
  62. package/src/generators/cypress-project/files/v9-and-under/src/support/index.ts__tmpl__ +17 -0
  63. package/src/generators/cypress-project/files/v9-and-under/tsconfig.json +10 -0
  64. package/src/generators/cypress-project/schema.d.ts +17 -0
  65. package/src/generators/cypress-project/schema.json +78 -0
  66. package/src/generators/init/init.d.ts +6 -0
  67. package/src/generators/init/init.js +97 -0
  68. package/src/generators/init/schema.d.ts +7 -0
  69. package/src/generators/init/schema.json +34 -0
  70. package/src/generators/migrate-to-cypress-11/conversion.util.d.ts +39 -0
  71. package/src/generators/migrate-to-cypress-11/conversion.util.js +246 -0
  72. package/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.d.ts +3 -0
  73. package/src/generators/migrate-to-cypress-11/migrate-to-cypress-11.js +93 -0
  74. package/src/generators/migrate-to-cypress-11/schema.json +15 -0
  75. package/src/migrations/update-15-0-0/add-cypress-inputs.d.ts +2 -0
  76. package/src/migrations/update-15-0-0/add-cypress-inputs.js +42 -0
  77. package/src/migrations/update-15-0-0/update-cy-mount-usage.d.ts +5 -0
  78. package/src/migrations/update-15-0-0/update-cy-mount-usage.js +119 -0
  79. package/src/migrations/update-15-1-0/cypress-11.d.ts +6 -0
  80. package/src/migrations/update-15-1-0/cypress-11.js +114 -0
  81. package/src/migrations/update-15-5-0/helpers.d.ts +3 -0
  82. package/src/migrations/update-15-5-0/helpers.js +39 -0
  83. package/src/migrations/update-15-5-0/update-to-cypress-12.d.ts +24 -0
  84. package/src/migrations/update-15-5-0/update-to-cypress-12.js +180 -0
  85. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.d.ts +2 -0
  86. package/src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages.js +9 -0
  87. package/src/migrations/update-16-2-0/update-cy-tsconfig.d.ts +3 -0
  88. package/src/migrations/update-16-2-0/update-cy-tsconfig.js +77 -0
  89. package/src/migrations/update-16-4-0/tsconfig-sourcemaps.d.ts +3 -0
  90. package/src/migrations/update-16-4-0/tsconfig-sourcemaps.js +62 -0
  91. package/src/migrations/update-16-8-0/cypress-13.d.ts +7 -0
  92. package/src/migrations/update-16-8-0/cypress-13.js +179 -0
  93. package/src/migrations/update-18-1-0/update-cypress-version-13-6-6.d.ts +2 -0
  94. package/src/migrations/update-18-1-0/update-cypress-version-13-6-6.js +12 -0
  95. package/src/plugins/plugin.d.ts +8 -0
  96. package/src/plugins/plugin.js +195 -0
  97. package/src/plugins/preprocessor-vite.d.ts +32 -0
  98. package/src/plugins/preprocessor-vite.js +97 -0
  99. package/src/utils/add-linter.d.ts +22 -0
  100. package/src/utils/add-linter.js +93 -0
  101. package/src/utils/config.d.ts +17 -0
  102. package/src/utils/config.js +115 -0
  103. package/src/utils/constants.d.ts +4 -0
  104. package/src/utils/constants.js +7 -0
  105. package/src/utils/ct-helpers.d.ts +16 -0
  106. package/src/utils/ct-helpers.js +86 -0
  107. package/src/utils/cypress-version.d.ts +5 -0
  108. package/src/utils/cypress-version.js +33 -0
  109. package/src/utils/find-target-options.d.ts +17 -0
  110. package/src/utils/find-target-options.js +136 -0
  111. package/src/utils/project-name.d.ts +3 -0
  112. package/src/utils/project-name.js +19 -0
  113. package/src/utils/start-dev-server.d.ts +9 -0
  114. package/src/utils/start-dev-server.js +157 -0
  115. package/src/utils/versions.d.ts +9 -0
  116. package/src/utils/versions.js +12 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2017-2023 Narwhal Technologies Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,68 @@
1
+ <p style="text-align: center;">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-dark.svg">
4
+ <img alt="Nx - Smart Monorepos · Fast CI" src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-light.svg" width="100%">
5
+ </picture>
6
+ </p>
7
+
8
+ <div style="text-align: center;">
9
+
10
+ [![CircleCI](https://circleci.com/gh/nrwl/nx.svg?style=svg)](https://circleci.com/gh/nrwl/nx)
11
+ [![License](https://img.shields.io/npm/l/@nx/workspace.svg?style=flat-square)]()
12
+ [![NPM Version](https://badge.fury.io/js/%40nrwl%2Fworkspace.svg)](https://www.npmjs.com/@nx/workspace)
13
+ [![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)]()
14
+ [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
15
+ [![Join the chat at https://gitter.im/nrwl-nx/community](https://badges.gitter.im/nrwl-nx/community.svg)](https://gitter.im/nrwl-nx/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
16
+ [![Join us on the Official Nx Discord Server](https://img.shields.io/discord/1143497901675401286?label=discord)](https://go.nx.dev/community)
17
+
18
+ </div>
19
+
20
+
21
+ <hr>
22
+
23
+ # Nx: Smart Monorepos · Fast CI
24
+
25
+ Nx is a build system with built-in tooling and advanced CI capabilities. It helps you maintain and scale monorepos, both locally and on CI.
26
+
27
+ This package is a [Cypress plugin for Nx](https://nx.dev/cypress/overview).
28
+
29
+ ## Getting Started
30
+
31
+ ### Creating an Nx Workspace
32
+
33
+ **Using `npx`**
34
+
35
+ ```bash
36
+ npx create-nx-workspace
37
+ ```
38
+
39
+ **Using `npm init`**
40
+
41
+ ```bash
42
+ npm init nx-workspace
43
+ ```
44
+
45
+ **Using `yarn create`**
46
+
47
+ ```bash
48
+ yarn create nx-workspace
49
+ ```
50
+
51
+ ### Adding Nx to an Existing Repository
52
+
53
+ Run:
54
+
55
+ ```bash
56
+ npx nx@latest init
57
+ ```
58
+
59
+ ## Documentation & Resources
60
+
61
+ - [Nx.Dev: Documentation, Guides, Tutorials](https://nx.dev)
62
+ - [Intro to Nx](https://nx.dev/getting-started/intro)
63
+ - [Official Nx YouTube Channel](https://www.youtube.com/@NxDevtools)
64
+ - [Blog Posts About Nx](https://blog.nrwl.io/nx/home)
65
+
66
+ <p style="text-align: center;"><a href="https://nx.dev/#learning-materials" target="_blank" rel="noreferrer"><img src="https://raw.githubusercontent.com/nrwl/nx/master/images/nx-courses-and-videos.svg"
67
+ width="100%" alt="Nx - Smart Monorepos · Fast CI"></a></p>
68
+
package/executors.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "executors": {
3
+ "cypress": {
4
+ "implementation": "./src/executors/cypress/cypress.impl",
5
+ "schema": "./src/executors/cypress/schema.json",
6
+ "description": "Run Cypress E2E tests."
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "Nx Cypress",
3
+ "version": "0.1",
4
+ "generators": {
5
+ "init": {
6
+ "factory": "./src/generators/init/init#cypressInitGeneratorInternal",
7
+ "schema": "./src/generators/init/schema.json",
8
+ "description": "Initialize the `@nrwl/cypress` plugin.",
9
+ "aliases": ["ng-add"],
10
+ "hidden": true
11
+ },
12
+ "cypress-project": {
13
+ "factory": "./src/generators/cypress-project/cypress-project#cypressProjectGeneratorInternal",
14
+ "schema": "./src/generators/cypress-project/schema.json",
15
+ "description": "Add a Cypress E2E Project.",
16
+ "hidden": true
17
+ },
18
+ "configuration": {
19
+ "aliases": ["cypress-e2e-configuration", "e2e", "e2e-config"],
20
+ "factory": "./src/generators/configuration/configuration#configurationGeneratorInternal",
21
+ "schema": "./src/generators/configuration/schema.json",
22
+ "description": "Add a Cypress E2E Configuration to an existing project."
23
+ },
24
+ "component-configuration": {
25
+ "aliases": ["cypress-component-configuration"],
26
+ "factory": "./src/generators/component-configuration/component-configuration#componentConfigurationGeneratorInternal",
27
+ "schema": "./src/generators/component-configuration/schema.json",
28
+ "description": "Set up Cypress Component Test for a project",
29
+ "hidden": true
30
+ },
31
+ "migrate-to-cypress-11": {
32
+ "factory": "./src/generators/migrate-to-cypress-11/migrate-to-cypress-11#migrateCypressProject",
33
+ "schema": "./src/generators/migrate-to-cypress-11/schema.json",
34
+ "description": "Migrate existing Cypress e2e projects to Cypress v11"
35
+ }
36
+ }
37
+ }
package/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { configurationGenerator } from './src/generators/configuration/configuration';
2
+ import { componentConfigurationGenerator } from './src/generators/component-configuration/component-configuration';
3
+ import { cypressProjectGenerator as _cypressProjectGenerator } from './src/generators/cypress-project/cypress-project';
4
+ export { configurationGenerator, componentConfigurationGenerator };
5
+ /** @deprecated Use `configurationGenerator` instead. It will be removed in Nx 19. */
6
+ export declare const cypressComponentConfiguration: typeof componentConfigurationGenerator;
7
+ export { configurationGenerator as cypressE2EConfigurationGenerator };
8
+ /** @deprecated Add a new project and call `configurationGenerator` instead. It will be removed in Nx 19. */
9
+ export declare const cypressProjectGenerator: typeof _cypressProjectGenerator;
10
+ export { cypressInitGenerator } from './src/generators/init/init';
11
+ export { migrateCypressProject } from './src/generators/migrate-to-cypress-11/migrate-to-cypress-11';
package/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateCypressProject = exports.cypressInitGenerator = exports.cypressProjectGenerator = exports.cypressE2EConfigurationGenerator = exports.cypressComponentConfiguration = exports.componentConfigurationGenerator = exports.configurationGenerator = void 0;
4
+ const configuration_1 = require("./src/generators/configuration/configuration");
5
+ Object.defineProperty(exports, "configurationGenerator", { enumerable: true, get: function () { return configuration_1.configurationGenerator; } });
6
+ Object.defineProperty(exports, "cypressE2EConfigurationGenerator", { enumerable: true, get: function () { return configuration_1.configurationGenerator; } });
7
+ const component_configuration_1 = require("./src/generators/component-configuration/component-configuration");
8
+ Object.defineProperty(exports, "componentConfigurationGenerator", { enumerable: true, get: function () { return component_configuration_1.componentConfigurationGenerator; } });
9
+ const cypress_project_1 = require("./src/generators/cypress-project/cypress-project");
10
+ // Maintain backwards compatibility with the old names in case community plugins used them.
11
+ // TODO(v19): Remove old name
12
+ /** @deprecated Use `configurationGenerator` instead. It will be removed in Nx 19. */
13
+ exports.cypressComponentConfiguration = component_configuration_1.componentConfigurationGenerator;
14
+ // TODO(v19): Remove project generator
15
+ /** @deprecated Add a new project and call `configurationGenerator` instead. It will be removed in Nx 19. */
16
+ exports.cypressProjectGenerator = cypress_project_1.cypressProjectGenerator;
17
+ var init_1 = require("./src/generators/init/init");
18
+ Object.defineProperty(exports, "cypressInitGenerator", { enumerable: true, get: function () { return init_1.cypressInitGenerator; } });
19
+ var migrate_to_cypress_11_1 = require("./src/generators/migrate-to-cypress-11/migrate-to-cypress-11");
20
+ Object.defineProperty(exports, "migrateCypressProject", { enumerable: true, get: function () { return migrate_to_cypress_11_1.migrateCypressProject; } });
@@ -0,0 +1,111 @@
1
+ {
2
+ "generators": {
3
+ "add-cypress-inputs": {
4
+ "cli": "nx",
5
+ "version": "15.0.0-beta.0",
6
+ "description": "Stop hashing cypress spec files and config files for build targets and dependent tasks",
7
+ "factory": "./src/migrations/update-15-0-0/add-cypress-inputs"
8
+ },
9
+ "update-cy-mount-usage": {
10
+ "cli": "nx",
11
+ "version": "15.0.0-beta.4",
12
+ "description": "Update to using cy.mount in the commands.ts file instead of importing mount for each component test file",
13
+ "factory": "./src/migrations/update-15-0-0/update-cy-mount-usage"
14
+ },
15
+ "update-to-cypress-11": {
16
+ "cli": "nx",
17
+ "version": "15.1.0-beta.0",
18
+ "description": "Update to Cypress v11. This migration will only update if the workspace is already on v10. https://www.cypress.io/blog/2022/11/04/upcoming-changes-to-component-testing/",
19
+ "factory": "./src/migrations/update-15-1-0/cypress-11"
20
+ },
21
+ "update-to-cypress-12": {
22
+ "cli": "nx",
23
+ "version": "15.5.0-beta.0",
24
+ "description": "Update to Cypress v12. Cypress 12 contains a handful of breaking changes that might causes tests to start failing that nx cannot directly fix. Read more Cypress 12 changes: https://docs.cypress.io/guides/references/migration-guide#Migrating-to-Cypress-12-0.This migration will only run if you are already using Cypress v11.",
25
+ "factory": "./src/migrations/update-15-5-0/update-to-cypress-12"
26
+ },
27
+ "update-16-0-0-add-nx-packages": {
28
+ "cli": "nx",
29
+ "version": "16.0.0-beta.1",
30
+ "description": "Replace @nrwl/cypress with @nx/cypress",
31
+ "implementation": "./src/migrations/update-16-0-0-add-nx-packages/update-16-0-0-add-nx-packages"
32
+ },
33
+ "update-16-2-0-normalize-tsconfigs": {
34
+ "cli": "nx",
35
+ "version": "16.2.0-beta.0",
36
+ "description": "Normalize tsconfig.cy.json files to be located at '<projectRoot>/cypress/tsconfig.json'",
37
+ "implementation": "./src/migrations/update-16-2-0/update-cy-tsconfig"
38
+ },
39
+ "update-16-3-0-remove-old-tsconfigs": {
40
+ "cli": "nx",
41
+ "version": "16.4.0-beta.10",
42
+ "description": "Remove tsconfig.e2e.json and add settings to project tsconfig.json. tsConfigs executor option is now deprecated. The project level tsconfig.json file should be used instead.",
43
+ "implementation": "./src/migrations/update-16-4-0/tsconfig-sourcemaps"
44
+ },
45
+ "update-16-8-0-cypress-13": {
46
+ "cli": "nx",
47
+ "version": "16.8.0-beta.4",
48
+ "description": "Update to Cypress v13. Most noteable change is video recording is off by default. This migration will only update if the workspace is already on Cypress v12. https://docs.cypress.io/guides/references/migration-guide#Migrating-to-Cypress-130",
49
+ "implementation": "./src/migrations/update-16-8-0/cypress-13"
50
+ },
51
+ "update-cypress-version-13-6-6": {
52
+ "cli": "nx",
53
+ "version": "18.1.0-beta.3",
54
+ "description": "Update to Cypress ^13.6.6 if the workspace is using Cypress v13 to ensure workspaces don't use v13.6.5 which has an issue when verifying Cypress.",
55
+ "implementation": "./src/migrations/update-18-1-0/update-cypress-version-13-6-6"
56
+ }
57
+ },
58
+ "packageJsonUpdates": {
59
+ "16.1.0": {
60
+ "version": "16.1.0-beta.0",
61
+ "requires": {
62
+ "cypress": ">=12.0.0 <12.11.0"
63
+ },
64
+ "packages": {
65
+ "cypress": {
66
+ "version": "^12.11.0",
67
+ "alwaysAddToPackageJson": false
68
+ }
69
+ }
70
+ },
71
+ "16.5.0": {
72
+ "version": "16.5.0-beta.0",
73
+ "requires": {
74
+ "cypress": ">=12.0.0 <12.16.0"
75
+ },
76
+ "packages": {
77
+ "cypress": {
78
+ "version": "^12.16.0",
79
+ "alwaysAddToPackageJson": false
80
+ }
81
+ }
82
+ },
83
+ "16.7.0": {
84
+ "version": "16.7.0-beta.3",
85
+ "packages": {
86
+ "eslint-plugin-cypress": {
87
+ "version": "^2.13.4",
88
+ "alwaysAddToPackageJson": false
89
+ }
90
+ }
91
+ },
92
+ "17.2.0-beta.2": {
93
+ "version": "17.2.0-beta.2",
94
+ "packages": {
95
+ "vite": {
96
+ "version": "^5.0.0",
97
+ "alwaysAddToPackageJson": false
98
+ }
99
+ }
100
+ },
101
+ "17.3.0": {
102
+ "version": "17.3.0-beta.3",
103
+ "packages": {
104
+ "@types/node": {
105
+ "version": "18.16.9",
106
+ "alwaysAddToPackageJson": false
107
+ }
108
+ }
109
+ }
110
+ }
111
+ }
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@nx/cypress",
3
+ "version": "0.0.0-pr-22179-271588f",
4
+ "private": false,
5
+ "description": "The Nx Plugin for Cypress contains executors and generators allowing your workspace to use the powerful Cypress integration testing capabilities.",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/nrwl/nx.git",
9
+ "directory": "packages/cypress"
10
+ },
11
+ "keywords": [
12
+ "Monorepo",
13
+ "Angular",
14
+ "React",
15
+ "Web",
16
+ "Node",
17
+ "Nest",
18
+ "Jest",
19
+ "Cypress",
20
+ "CLI"
21
+ ],
22
+ "main": "./index.js",
23
+ "typings": "./index.d.ts",
24
+ "author": "Victor Savkin",
25
+ "license": "MIT",
26
+ "bugs": {
27
+ "url": "https://github.com/nrwl/nx/issues"
28
+ },
29
+ "homepage": "https://nx.dev",
30
+ "generators": "./generators.json",
31
+ "executors": "./executors.json",
32
+ "ng-update": {
33
+ "requirements": {},
34
+ "migrations": "./migrations.json"
35
+ },
36
+ "dependencies": {
37
+ "@nx/devkit": "0.0.0-pr-22179-271588f",
38
+ "@nx/eslint": "0.0.0-pr-22179-271588f",
39
+ "@nx/js": "0.0.0-pr-22179-271588f",
40
+ "@phenomnomnominal/tsquery": "~5.0.1",
41
+ "detect-port": "^1.5.1",
42
+ "semver": "^7.5.3",
43
+ "tslib": "^2.3.0",
44
+ "@nrwl/cypress": "0.0.0-pr-22179-271588f"
45
+ },
46
+ "peerDependencies": {
47
+ "cypress": ">= 3 < 14"
48
+ },
49
+ "peerDependenciesMeta": {
50
+ "cypress": {
51
+ "optional": true
52
+ }
53
+ },
54
+ "publishConfig": {
55
+ "access": "public"
56
+ },
57
+ "type": "commonjs"
58
+ }
package/plugin.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { createNodes, createDependencies } from './src/plugins/plugin';
package/plugin.js ADDED
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createDependencies = exports.createNodes = void 0;
4
+ var plugin_1 = require("./src/plugins/plugin");
5
+ Object.defineProperty(exports, "createNodes", { enumerable: true, get: function () { return plugin_1.createNodes; } });
6
+ Object.defineProperty(exports, "createDependencies", { enumerable: true, get: function () { return plugin_1.createDependencies; } });
@@ -0,0 +1,69 @@
1
+ interface BaseCypressPreset {
2
+ videosFolder: string;
3
+ screenshotsFolder: string;
4
+ chromeWebSecurity: boolean;
5
+ }
6
+ export interface NxComponentTestingOptions {
7
+ /**
8
+ * the component testing target name.
9
+ * this is only when customized away from the default value of `component-test`
10
+ * @example 'component-test'
11
+ */
12
+ ctTargetName?: string;
13
+ buildTarget?: string;
14
+ bundler?: 'vite' | 'webpack';
15
+ compiler?: 'swc' | 'babel';
16
+ }
17
+ export declare function nxBaseCypressPreset(pathToConfig: string, options?: {
18
+ testingType: 'component' | 'e2e';
19
+ }): BaseCypressPreset;
20
+ /**
21
+ * nx E2E Preset for Cypress
22
+ * @description
23
+ * this preset contains the base configuration
24
+ * for your e2e tests that nx recommends.
25
+ * you can easily extend this within your cypress config via spreading the preset
26
+ * @example
27
+ * export default defineConfig({
28
+ * e2e: {
29
+ * ...nxE2EPreset(__dirname)
30
+ * // add your own config here
31
+ * }
32
+ * })
33
+ *
34
+ */
35
+ export declare function nxE2EPreset(pathToConfig: string, options?: NxCypressE2EPresetOptions): any;
36
+ export interface WebServerConfig {
37
+ /**
38
+ * Timeout to wait for the webserver to start listening
39
+ */
40
+ timeout?: number;
41
+ /**
42
+ * Reuse an existing web server if it exists
43
+ * If this is false, an error will be thrown if the server is already running
44
+ */
45
+ reuseExistingServer?: boolean;
46
+ }
47
+ export type NxCypressE2EPresetOptions = {
48
+ bundler?: string;
49
+ /**
50
+ * The directory from the project root, where the cypress files (support, fixtures, specs) are located.
51
+ * i.e. 'cypress/' or 'src'
52
+ * default is 'src'
53
+ **/
54
+ cypressDir?: string;
55
+ /**
56
+ * A map of commandName -> command to start the web server for testing.
57
+ * Currently only default is read.
58
+ */
59
+ webServerCommands?: Record<string, string>;
60
+ /**
61
+ * A command to start the web server - used for e2e tests distributed by Nx.
62
+ */
63
+ ciWebServerCommand?: string;
64
+ /**
65
+ * Configures how the web server command is started and monitored.
66
+ */
67
+ webServerConfig?: WebServerConfig;
68
+ };
69
+ export {};
@@ -0,0 +1,154 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.nxE2EPreset = exports.nxBaseCypressPreset = void 0;
4
+ const devkit_1 = require("@nx/devkit");
5
+ const path_1 = require("path");
6
+ const fs_1 = require("fs");
7
+ const preprocessor_vite_1 = require("../src/plugins/preprocessor-vite");
8
+ const constants_1 = require("../src/utils/constants");
9
+ const child_process_1 = require("child_process");
10
+ const http_1 = require("http");
11
+ const https_1 = require("https");
12
+ function nxBaseCypressPreset(pathToConfig, options) {
13
+ // used to set babel settings for react CT.
14
+ process.env.NX_CYPRESS_COMPONENT_TEST =
15
+ options?.testingType === 'component' ? 'true' : 'false';
16
+ // prevent from placing path outside the root of the workspace
17
+ // if they pass in a file or directory
18
+ const normalizedPath = (0, fs_1.lstatSync)(pathToConfig).isDirectory()
19
+ ? pathToConfig
20
+ : (0, path_1.dirname)(pathToConfig);
21
+ const projectPath = (0, path_1.relative)(devkit_1.workspaceRoot, normalizedPath);
22
+ const offset = (0, path_1.relative)(normalizedPath, devkit_1.workspaceRoot);
23
+ const videosFolder = (0, path_1.join)(offset, 'dist', 'cypress', projectPath, 'videos');
24
+ const screenshotsFolder = (0, path_1.join)(offset, 'dist', 'cypress', projectPath, 'screenshots');
25
+ return {
26
+ videosFolder,
27
+ screenshotsFolder,
28
+ chromeWebSecurity: false,
29
+ };
30
+ }
31
+ exports.nxBaseCypressPreset = nxBaseCypressPreset;
32
+ function startWebServer(webServerCommand) {
33
+ const serverProcess = (0, child_process_1.spawn)(webServerCommand, {
34
+ cwd: devkit_1.workspaceRoot,
35
+ shell: true,
36
+ // Detaching the process on unix will create a process group, allowing us to kill it later
37
+ // Windows is fine so we leave it attached to this process
38
+ detached: process.platform !== 'win32',
39
+ stdio: 'inherit',
40
+ });
41
+ return () => {
42
+ if (process.platform === 'win32') {
43
+ serverProcess.kill();
44
+ }
45
+ else {
46
+ // child.kill() does not work on linux
47
+ // process.kill will kill the whole process group on unix
48
+ process.kill(-serverProcess.pid, 'SIGKILL');
49
+ }
50
+ };
51
+ }
52
+ /**
53
+ * nx E2E Preset for Cypress
54
+ * @description
55
+ * this preset contains the base configuration
56
+ * for your e2e tests that nx recommends.
57
+ * you can easily extend this within your cypress config via spreading the preset
58
+ * @example
59
+ * export default defineConfig({
60
+ * e2e: {
61
+ * ...nxE2EPreset(__dirname)
62
+ * // add your own config here
63
+ * }
64
+ * })
65
+ *
66
+ */
67
+ function nxE2EPreset(pathToConfig, options) {
68
+ const basePath = options?.cypressDir || 'src';
69
+ const baseConfig /*Cypress.EndToEndConfigOptions & {
70
+ [NX_PLUGIN_OPTIONS]: unknown;
71
+ }*/ = {
72
+ ...nxBaseCypressPreset(pathToConfig),
73
+ fileServerFolder: '.',
74
+ supportFile: `${basePath}/support/e2e.{js,ts}`,
75
+ specPattern: `${basePath}/**/*.cy.{js,jsx,ts,tsx}`,
76
+ fixturesFolder: `${basePath}/fixtures`,
77
+ [constants_1.NX_PLUGIN_OPTIONS]: {
78
+ webServerCommand: options?.webServerCommands?.default,
79
+ webServerCommands: options?.webServerCommands,
80
+ ciWebServerCommand: options?.ciWebServerCommand,
81
+ },
82
+ async setupNodeEvents(on, config) {
83
+ const webServerCommands = config.env?.webServerCommands ?? options?.webServerCommands;
84
+ const webServerCommand = config.env?.webServerCommand ?? webServerCommands?.default;
85
+ if (options?.bundler === 'vite') {
86
+ on('file:preprocessor', (0, preprocessor_vite_1.default)());
87
+ }
88
+ if (!options?.webServerCommands) {
89
+ return;
90
+ }
91
+ if (!webServerCommand) {
92
+ return;
93
+ }
94
+ if (config.baseUrl && webServerCommand) {
95
+ if (await isServerUp(config.baseUrl)) {
96
+ if (options?.webServerConfig?.reuseExistingServer === undefined
97
+ ? true
98
+ : options.webServerConfig.reuseExistingServer) {
99
+ console.log(`Reusing the server already running on ${config.baseUrl}`);
100
+ return;
101
+ }
102
+ else {
103
+ throw new Error(`Web server is already running at ${config.baseUrl}`);
104
+ }
105
+ }
106
+ const killWebServer = startWebServer(webServerCommand);
107
+ on('after:run', () => {
108
+ killWebServer();
109
+ });
110
+ await waitForServer(config.baseUrl, options.webServerConfig);
111
+ }
112
+ },
113
+ };
114
+ return baseConfig;
115
+ }
116
+ exports.nxE2EPreset = nxE2EPreset;
117
+ function waitForServer(url, webServerConfig) {
118
+ return new Promise((resolve, reject) => {
119
+ let pollTimeout;
120
+ const { protocol } = new URL(url);
121
+ const timeoutDuration = webServerConfig?.timeout ?? 60 * 1000;
122
+ const timeout = setTimeout(() => {
123
+ clearTimeout(pollTimeout);
124
+ reject(new Error(`Web server failed to start in ${timeoutDuration}ms. This can be configured in cypress.config.ts.`));
125
+ }, timeoutDuration);
126
+ const makeRequest = protocol === 'https:' ? https_1.request : http_1.request;
127
+ function pollForServer() {
128
+ const request = makeRequest(url, () => {
129
+ clearTimeout(timeout);
130
+ resolve();
131
+ });
132
+ request.on('error', () => {
133
+ pollTimeout = setTimeout(pollForServer, 100);
134
+ });
135
+ // Don't forget to end the request
136
+ request.end();
137
+ }
138
+ pollForServer();
139
+ });
140
+ }
141
+ function isServerUp(url) {
142
+ const { protocol } = new URL(url);
143
+ const makeRequest = protocol === 'https:' ? https_1.request : http_1.request;
144
+ return new Promise((resolve) => {
145
+ const request = makeRequest(url, () => {
146
+ resolve(true);
147
+ });
148
+ request.on('error', () => {
149
+ resolve(false);
150
+ });
151
+ // Don't forget to end the request
152
+ request.end();
153
+ });
154
+ }
@@ -0,0 +1,40 @@
1
+ import { ExecutorContext } from '@nx/devkit';
2
+ export type Json = {
3
+ [k: string]: any;
4
+ };
5
+ export interface CypressExecutorOptions extends Json {
6
+ cypressConfig: string;
7
+ watch?: boolean;
8
+ devServerTarget?: string;
9
+ headed?: boolean;
10
+ /**
11
+ * @deprecated use watch instead
12
+ **/
13
+ headless?: boolean;
14
+ exit?: boolean;
15
+ key?: string;
16
+ record?: boolean;
17
+ parallel?: boolean;
18
+ baseUrl?: string;
19
+ browser?: string;
20
+ env?: Record<string, string>;
21
+ spec?: string;
22
+ /**
23
+ * @deprecated no longer used since cypress supports typescript out of the box
24
+ **/
25
+ copyFiles?: string;
26
+ ciBuildId?: string | number;
27
+ group?: string;
28
+ ignoreTestFiles?: string | string[];
29
+ reporter?: string;
30
+ reporterOptions?: string | Json;
31
+ skipServe?: boolean;
32
+ testingType?: 'component' | 'e2e';
33
+ tag?: string;
34
+ port?: number | 'cypress-auto';
35
+ quiet?: boolean;
36
+ runnerUi?: boolean;
37
+ }
38
+ export default function cypressExecutor(options: CypressExecutorOptions, context: ExecutorContext): Promise<{
39
+ success: any;
40
+ }>;