Skip to content

Commit

Permalink
fix(testing): update the cypress plugin implementation (nrwl#20314)
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenPandaz authored Nov 21, 2023
1 parent 5d82a2a commit a916794
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 285 deletions.
5 changes: 0 additions & 5 deletions packages/cypress/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,6 @@
"version": "17.2.0-beta.0",
"description": "Add devServerTargets into cypress.config.ts files for @nx/cypress/plugin",
"implementation": "./src/migrations/update-17-2-0/add-dev-server-targets-to-cypress-configs"
},
"add-nx-cypress-plugin": {
"version": "17.2.0-beta.0",
"description": "Add the @nx/cypress/plugin to nx.json plugins",
"implementation": "./src/migrations/update-17-2-0/add-nx-cypress-plugin"
}
},
"packageJsonUpdates": {
Expand Down
2 changes: 0 additions & 2 deletions packages/cypress/plugins/cypress-preset.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import {
createProjectGraphAsync,
logger,
parseTargetString,
workspaceRoot,
} from '@nx/devkit';
import { dirname, join, relative } from 'path';
import { lstatSync } from 'fs';

import vitePreprocessor from '../src/plugins/preprocessor-vite';
import { ChildProcess, fork } from 'node:child_process';
import { createExecutorContext } from '../src/utils/ct-helpers';
import { startDevServer } from '../src/utils/start-dev-server';

Expand Down

This file was deleted.

This file was deleted.

81 changes: 52 additions & 29 deletions packages/cypress/src/plugins/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ describe('@nx/cypress/plugin', () => {
mockCypressConfig(
defineConfig({
e2e: {
env: {
devServerTargets: {
default: 'my-app:serve',
production: 'my-app:serve:production',
},
},
videosFolder: './dist/videos',
screenshotsFolder: './dist/screenshots',
},
Expand All @@ -58,18 +64,25 @@ describe('@nx/cypress/plugin', () => {
"targets": {
"e2e": {
"cache": true,
"executor": "@nx/cypress:cypress",
"command": "cypress run --config-file cypress.config.js --e2e",
"configurations": {
"production": {
"command": "cypress run --config-file cypress.config.js --e2e --env.devServerTarget my-app:serve:production",
},
},
"inputs": [
"default",
"^production",
{
"externalDependencies": [
"cypress",
],
},
],
"options": {
"cypressConfig": "cypress.config.js",
"testingType": "e2e",
"cwd": ".",
},
"outputs": [
"{options.videosFolder}",
"{options.screenshotsFolder}",
"{projectRoot}/dist/videos",
"{projectRoot}/dist/screenshots",
],
Expand Down Expand Up @@ -110,18 +123,20 @@ describe('@nx/cypress/plugin', () => {
"targets": {
"component-test": {
"cache": true,
"executor": "@nx/cypress:cypress",
"command": "cypress open --config-file cypress.config.js --component",
"inputs": [
"default",
"^production",
{
"externalDependencies": [
"cypress",
],
},
],
"options": {
"cypressConfig": "cypress.config.js",
"testingType": "component",
"cwd": ".",
},
"outputs": [
"{options.videosFolder}",
"{options.screenshotsFolder}",
"{projectRoot}/dist/videos",
"{projectRoot}/dist/screenshots",
],
Expand All @@ -138,6 +153,8 @@ describe('@nx/cypress/plugin', () => {
defineConfig({
e2e: {
specPattern: '**/*.cy.ts',
videosFolder: './dist/videos',
screenshotsFolder: './dist/screenshots',
env: {
devServerTargets: {
default: 'my-app:serve',
Expand All @@ -164,24 +181,27 @@ describe('@nx/cypress/plugin', () => {
"targets": {
"e2e": {
"cache": true,
"command": "cypress run --config-file cypress.config.js --e2e",
"configurations": {
"production": {
"devServerTarget": "my-app:serve:production",
"command": "cypress run --config-file cypress.config.js --e2e --env.devServerTarget my-app:serve:production",
},
},
"executor": "@nx/cypress:cypress",
"inputs": [
"default",
"^production",
{
"externalDependencies": [
"cypress",
],
},
],
"options": {
"cypressConfig": "cypress.config.js",
"devServerTarget": "my-app:serve",
"testingType": "e2e",
"cwd": ".",
},
"outputs": [
"{options.videosFolder}",
"{options.screenshotsFolder}",
"{projectRoot}/dist/videos",
"{projectRoot}/dist/screenshots",
],
},
"e2e-ci": {
Expand All @@ -197,29 +217,32 @@ describe('@nx/cypress/plugin', () => {
"inputs": [
"default",
"^production",
{
"externalDependencies": [
"cypress",
],
},
],
"outputs": [
"{options.videosFolder}",
"{options.screenshotsFolder}",
"{projectRoot}/dist/videos",
"{projectRoot}/dist/screenshots",
],
},
"e2e-ci--test.cy.ts": {
"cache": true,
"configurations": undefined,
"executor": "@nx/cypress:cypress",
"command": "cypress run --config-file cypress.config.js --e2e --env.devServerTarget my-app:serve-static --spec test.cy.ts",
"inputs": [
"default",
"^production",
{
"externalDependencies": [
"cypress",
],
},
],
"options": {
"cypressConfig": "cypress.config.js",
"devServerTarget": "my-app:serve-static",
"spec": "test.cy.ts",
"testingType": "e2e",
},
"outputs": [
"{options.videosFolder}",
"{options.screenshotsFolder}",
"{projectRoot}/dist/videos",
"{projectRoot}/dist/screenshots",
],
},
},
Expand Down
Loading

0 comments on commit a916794

Please sign in to comment.