Skip to content

The @nx/cypress plugin provides various migrations to help you migrate to newer versions of cypress projects within your Nx workspace. Below is a complete reference for all available migrations.

Version: 22.3.2-beta.0

The following packages will be updated:

NameVersionAlways add to package.json
cypress^15.8.0Updated only
@cypress/webpack-dev-server^5.4.1Updated only

Version: 22.1.0-beta.6

Renames cy.exec().its('code') usages to the new exitCode property introduced in Cypress v15.

NameVersion
cypress>=15.0.0

Rename cy.exec().its('code') to cy.exec().its('exitCode')

Section titled “Rename cy.exec().its('code') to cy.exec().its('exitCode')”

Cypress v15 renamed the result property exposed by cy.exec() from code to exitCode. This migration updates Cypress spec files managed by Nx so that assertions such as cy.exec(...).its('code') use the new exitCode property.

Read more in the migration guide.

apps/app-e2e/src/e2e/sample.cy.ts
cy.exec('echo 0').its('code').should('eq', 0);
apps/app-e2e/src/e2e/sample.cy.ts
cy.exec('echo 0').its('exitCode').should('eq', 0);

Version: 22.1.0-beta.6

Updates the deprecated Cypress.SelectorPlayground API to Cypress.ElementSelector and removes the unsupported onElement option.

NameVersion
cypress>=15.0.0

Cypress v15 renamed Cypress.SelectorPlayground to Cypress.ElementSelector and removed the deprecated onElement option when calling Cypress.ElementSelector.defaults(). This migration updates existing Cypress support files to use the new API.

Read more in the migration guide.

apps/web-e2e/src/support/selector.ts
Cypress.SelectorPlayground.defaults({
selectorPriority: ['data-cy'],
onElement: (el) => el,
});
apps/web-e2e/src/support/selector.ts
Cypress.ElementSelector.defaults({
selectorPriority: ['data-cy'],
});

Version: 22.1.0-beta.6

For Angular component testing projects below v18, switches to the fallback @cypress/angular harness required by Cypress v15.

NameVersion
cypress>=15.0.0

Use the fallback Angular component testing harness for Cypress v15

Section titled “Use the fallback Angular component testing harness for Cypress v15”

Cypress v15 requires Angular component testing projects running Angular versions below 18 to migrate from the built-in cypress/angular helper to the @cypress/angular harness (v3). This migration updates component testing imports and ensures the correct dependency is installed.

Read more in the migration guide.

apps/dashboard/src/app/app.component.cy.ts
import { mount } from 'cypress/angular';
apps/dashboard/src/app/app.component.cy.ts
import { mount } from '@cypress/angular';

Version: 22.1.0-beta.6

The following packages will be updated:

NameVersionAlways add to package.json
cypress^15.6.0Updated only
@cypress/vite-dev-server^7.0.1Updated only
@cypress/webpack-dev-server^5.1.4Updated only

remove-tsconfig-and-copy-files-options-from-cypress-executor

Section titled “remove-tsconfig-and-copy-files-options-from-cypress-executor”

Version: 21.0.0-beta.10

Removes the tsConfig and copyFiles options from the @nx/cypress:cypress executor.

Remove tsConfig and copyFiles Options from Cypress Executor

Section titled “Remove tsConfig and copyFiles Options from Cypress Executor”

Removes the previously deprecated and unused tsConfig and copyFiles options from the @nx/cypress:cypress executor configuration in all projects.

Remove the options from the project configuration:

apps/app1-e2e/project.json
{
"targets": {
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/app1-e2e/cypress.config.ts",
"tsConfig": "apps/app1-e2e/tsconfig.json",
"copyFiles": "**/*.spec.ts",
"devServerTarget": "app1:serve"
}
}
}
}
apps/app1-e2e/project.json
{
"targets": {
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/app1-e2e/cypress.config.ts",
"devServerTarget": "app1:serve"
}
}
}
}

Remove the options from a target default using the @nx/cypress:cypress executor:

nx.json
{
"targetDefaults": {
"e2e": {
"cache": true,
"executor": "@nx/cypress:cypress",
"options": {
"tsConfig": "{projectRoot}/tsconfig.json",
"copyFiles": "**/*.spec.ts"
}
}
}
}
nx.json
{
"targetDefaults": {
"e2e": {
"cache": true,
"executor": "@nx/cypress:cypress"
}
}
}

Remove the options from a target default using the @nx/cypress:cypress executor as the key:

nx.json
{
"targetDefaults": {
"@nx/cypress:cypress": {
"cache": true,
"options": {
"tsConfig": "{projectRoot}/tsconfig.json",
"copyFiles": "**/*.spec.ts"
}
}
}
}
nx.json
{
"targetDefaults": {
"@nx/cypress:cypress": {
"cache": true
}
}
}

Version: 20.8.0-beta.0

Replaces the experimentalSkipDomainInjection configuration option with the new injectDocumentDomain configuration option.

NameVersion
cypress>=14.0.0

Set injectDocumentDomain Configuration Option

Section titled “Set injectDocumentDomain Configuration Option”

Replaces the removed experimentalSkipDomainInjection configuration option with the new injectDocumentDomain configuration option when needed. Skipping domain injection is the default behavior in Cypress v14 and therefore, it is required to use the cy.origin() command when navigating between domains. The injectDocumentDomain option was introduced to ease the transition to v14, but it is deprecated and will be removed in Cypress v15. Read more at the migration notes.

If the experimentalSkipDomainInjection configuration option is present, the migration will remove it. This is to account for the fact that skipping domain injection is the default behavior in Cypress v14.

apps/app1-e2e/cypress.config.ts
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
...nxE2EPreset(__filename, {
cypressDir: 'src',
bundler: 'vite',
webServerCommands: {
default: 'pnpm exec nx run app1:dev',
production: 'pnpm exec nx run app1:dev',
},
ciWebServerCommand: 'pnpm exec nx run app1:dev',
ciBaseUrl: 'http://localhost:4200',
}),
baseUrl: 'http://localhost:4200',
experimentalSkipDomainInjection: ['https://example.com'],
},
});
apps/app1-e2e/cypress.config.ts
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
...nxE2EPreset(__filename, {
cypressDir: 'src',
bundler: 'vite',
webServerCommands: {
default: 'pnpm exec nx run app1:dev',
production: 'pnpm exec nx run app1:dev',
},
ciWebServerCommand: 'pnpm exec nx run app1:dev',
ciBaseUrl: 'http://localhost:4200',
}),
baseUrl: 'http://localhost:4200',
},
});

If the experimentalSkipDomainInjection configuration option is present and set to an empty array (no domain injection is skipped), the migration will remove it and will set the injectDocumentDomain option to true.

apps/app1-e2e/cypress.config.ts
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
...nxE2EPreset(__filename, {
cypressDir: 'src',
bundler: 'vite',
webServerCommands: {
default: 'pnpm exec nx run app1:dev',
production: 'pnpm exec nx run app1:dev',
},
ciWebServerCommand: 'pnpm exec nx run app1:dev',
ciBaseUrl: 'http://localhost:4200',
}),
baseUrl: 'http://localhost:4200',
experimentalSkipDomainInjection: [],
},
});
apps/app1-e2e/cypress.config.ts
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
...nxE2EPreset(__filename, {
cypressDir: 'src',
bundler: 'vite',
webServerCommands: {
default: 'pnpm exec nx run app1:dev',
production: 'pnpm exec nx run app1:dev',
},
ciWebServerCommand: 'pnpm exec nx run app1:dev',
ciBaseUrl: 'http://localhost:4200',
}),
baseUrl: 'http://localhost:4200',
// Please ensure you use `cy.origin()` when navigating between domains and remove this option.
// See https://docs.cypress.io/app/references/migration-guide#Changes-to-cyorigin
injectDocumentDomain: true,
},
});

If the experimentalSkipDomainInjection configuration option is not present (no domain injection is skipped), the migration will set the injectDocumentDomain option to true.

apps/app1-e2e/cypress.config.ts
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
...nxE2EPreset(__filename, {
cypressDir: 'src',
bundler: 'vite',
webServerCommands: {
default: 'pnpm exec nx run app1:dev',
production: 'pnpm exec nx run app1:dev',
},
ciWebServerCommand: 'pnpm exec nx run app1:dev',
ciBaseUrl: 'http://localhost:4200',
}),
baseUrl: 'http://localhost:4200',
},
});
apps/app1-e2e/cypress.config.ts
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
...nxE2EPreset(__filename, {
cypressDir: 'src',
bundler: 'vite',
webServerCommands: {
default: 'pnpm exec nx run app1:dev',
production: 'pnpm exec nx run app1:dev',
},
ciWebServerCommand: 'pnpm exec nx run app1:dev',
ciBaseUrl: 'http://localhost:4200',
}),
baseUrl: 'http://localhost:4200',
// Please ensure you use `cy.origin()` when navigating between domains and remove this option.
// See https://docs.cypress.io/app/references/migration-guide#Changes-to-cyorigin
injectDocumentDomain: true,
},
});

Version: 20.8.0-beta.0

Removes the experimentalFetchPolyfill configuration option.

NameVersion
cypress>=14.0.0

Remove experimentalFetchPolyfill Configuration Option

Section titled “Remove experimentalFetchPolyfill Configuration Option”

Removes the experimentalFetchPolyfill configuration option that was removed in Cypress v14. Read more at the migration notes.

apps/app1-e2e/cypress.config.ts
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
...nxE2EPreset(__filename, {
cypressDir: 'src',
bundler: 'vite',
webServerCommands: {
default: 'pnpm exec nx run app1:dev',
production: 'pnpm exec nx run app1:dev',
},
ciWebServerCommand: 'pnpm exec nx run app1:dev',
ciBaseUrl: 'http://localhost:4200',
}),
baseUrl: 'http://localhost:4200',
experimentalFetchPolyfill: true,
},
});
apps/app1-e2e/cypress.config.ts
import { nxE2EPreset } from '@nx/cypress/plugins/cypress-preset';
import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
...nxE2EPreset(__filename, {
cypressDir: 'src',
bundler: 'vite',
webServerCommands: {
default: 'pnpm exec nx run app1:dev',
production: 'pnpm exec nx run app1:dev',
},
ciWebServerCommand: 'pnpm exec nx run app1:dev',
ciBaseUrl: 'http://localhost:4200',
}),
baseUrl: 'http://localhost:4200',
},
});

Version: 20.8.0-beta.0

Replaces the experimentalJustInTimeCompile configuration option with the new justInTimeCompile configuration option.

NameVersion
cypress>=14.0.0

Replace the experimentalJustInTimeCompile Configuration Option with justInTimeCompile

Section titled “Replace the experimentalJustInTimeCompile Configuration Option with justInTimeCompile”

Replaces the experimentalJustInTimeCompile configuration option with the new justInTimeCompile configuration option. Read more at the migration notes.

If the experimentalJustInTimeCompile configuration option is present and set to true, the migration will remove it. This is to account for the fact that JIT compilation is the default behavior in Cypress v14.

apps/app1/cypress.config.ts
import { defineConfig } from 'cypress';
export default defineConfig({
component: {
devServer: {
framework: 'angular',
bundler: 'webpack',
},
experimentalJustInTimeCompile: true,
},
});
apps/app1/cypress.config.ts
import { defineConfig } from 'cypress';
export default defineConfig({
component: {
devServer: {
framework: 'angular',
bundler: 'webpack',
},
},
});

If the experimentalJustInTimeCompile configuration option is set to false and it is using webpack, the migration will rename it to justInTimeCompile.

apps/app1/cypress.config.ts
import { defineConfig } from 'cypress';
export default defineConfig({
component: {
devServer: {
framework: 'angular',
bundler: 'webpack',
},
experimentalJustInTimeCompile: false,
},
});
apps/app1/cypress.config.ts
import { defineConfig } from 'cypress';
export default defineConfig({
component: {
devServer: {
framework: 'angular',
bundler: 'webpack',
},
justInTimeCompile: false,
},
});

If the experimentalJustInTimeCompile configuration is set to any value and it is using Vite, the migration will remove it. This is to account for the fact that JIT compilation no longer applies to Vite.

apps/app1/cypress.config.ts
import { defineConfig } from 'cypress';
export default defineConfig({
component: {
devServer: {
framework: 'react',
bundler: 'vite',
},
experimentalJustInTimeCompile: false,
},
});
apps/app1/cypress.config.ts
import { defineConfig } from 'cypress';
export default defineConfig({
component: {
devServer: {
framework: 'react',
bundler: 'vite',
},
},
});

Version: 20.8.0-beta.0

Updates the module specifier for the Component Testing mount function.

NameVersion
cypress>=14.0.0

Updates the relevant module specifiers when importing the mount function and using the Angular or React frameworks. Read more at the Angular migration notes and the React migration notes.

If using the Angular framework with a version greater than or equal to v17.2.0 and importing the mount function from the cypress/angular-signals module, the migration will update the import to use the cypress/angular module.

apps/app1/cypress/support/component.ts
import { mount } from 'cypress/angular-signals';
import './commands';
declare global {
namespace Cypress {
interface Chainable<Subject> {
mount: typeof mount;
}
}
}
Cypress.Commands.add('mount', mount);
apps/app1/cypress/support/component.ts
import { mount } from 'cypress/angular';
import './commands';
declare global {
namespace Cypress {
interface Chainable<Subject> {
mount: typeof mount;
}
}
}
Cypress.Commands.add('mount', mount);

If using the Angular framework with a version lower than v17.2.0 and importing the mount function from the cypress/angular module, the migration will install the @cypress/angular@2 package and update the import to use the @cypress/angular module.

package.json
{
"name": "@my-repo/source",
"dependencies": {
...
"cypress": "^14.2.1"
}
}
apps/app1/cypress/support/component.ts
import { mount } from 'cypress/angular';
import './commands';
declare global {
namespace Cypress {
interface Chainable<Subject> {
mount: typeof mount;
}
}
}
Cypress.Commands.add('mount', mount);
package.json
{
"name": "@my-repo/source",
"dependencies": {
...
"cypress": "^14.2.1",
"@cypress/angular": "^2.1.0"
}
}
apps/app1/cypress/support/component.ts
import { mount } from '@cypress/angular';
import './commands';
declare global {
namespace Cypress {
interface Chainable<Subject> {
mount: typeof mount;
}
}
}
Cypress.Commands.add('mount', mount);

If using the React framework and importing the mount function from the cypress/react18 module, the migration will update the import to use the cypress/react module.

apps/app1/cypress/support/component.ts
import { mount } from 'cypress/react18';
import './commands';
declare global {
namespace Cypress {
interface Chainable<Subject> {
mount: typeof mount;
}
}
}
Cypress.Commands.add('mount', mount);
apps/app1/cypress/support/component.ts
import { mount } from 'cypress/react';
import './commands';
declare global {
namespace Cypress {
interface Chainable<Subject> {
mount: typeof mount;
}
}
}
Cypress.Commands.add('mount', mount);

Version: 20.8.0-beta.0

The following packages will be updated:

NameVersionAlways add to package.json
cypress^14.2.1Updated only
@cypress/vite-dev-server^6.0.3Updated only
@cypress/webpack-dev-server^4.0.2Updated only