Skip to content

Commit

Permalink
feat(testing): infer open-cypress task
Browse files Browse the repository at this point in the history
  • Loading branch information
leosvelperez committed Mar 28, 2024
1 parent 4b75255 commit 99cfe51
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,9 @@ describe('app', () => {
[
{
"options": {
"ciTargetName": "e2e-ci",
"componentTestingTargetName": "component-test",
"openTargetName": "open-cypress",
"targetName": "e2e",
},
"plugin": "@nx/cypress/plugin",
Expand Down
2 changes: 2 additions & 0 deletions packages/cypress/src/generators/init/init.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ describe('init', () => {
"plugins": [
{
"options": {
"ciTargetName": "e2e-ci",
"componentTestingTargetName": "component-test",
"openTargetName": "open-cypress",
"targetName": "e2e",
},
"plugin": "@nx/cypress/plugin",
Expand Down
2 changes: 2 additions & 0 deletions packages/cypress/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ export function addPlugin(tree: Tree) {
options: {
targetName: 'e2e',
componentTestingTargetName: 'component-test',
ciTargetName: 'e2e-ci',
openTargetName: 'open-cypress',
} as CypressPluginOptions,
});
updateNxJson(tree, nxJson);
Expand Down
18 changes: 18 additions & 0 deletions packages/cypress/src/plugins/plugin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ describe('@nx/cypress/plugin', () => {
"{projectRoot}/dist/screenshots",
],
},
"open-cypress": {
"command": "cypress open",
"options": {
"cwd": ".",
},
},
},
},
},
Expand Down Expand Up @@ -161,6 +167,12 @@ describe('@nx/cypress/plugin', () => {
"{projectRoot}/dist/screenshots",
],
},
"open-cypress": {
"command": "cypress open",
"options": {
"cwd": ".",
},
},
},
},
},
Expand Down Expand Up @@ -279,6 +291,12 @@ describe('@nx/cypress/plugin', () => {
"{projectRoot}/dist/cypress/screenshots",
],
},
"open-cypress": {
"command": "cypress open",
"options": {
"cwd": ".",
},
},
},
},
},
Expand Down
7 changes: 7 additions & 0 deletions packages/cypress/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { loadConfigFile } from '@nx/devkit/src/utils/config-utils';
export interface CypressPluginOptions {
ciTargetName?: string;
targetName?: string;
openTargetName?: string;
componentTestingTargetName?: string;
}

Expand Down Expand Up @@ -268,12 +269,18 @@ async function buildCypressTargets(
};
}

targets[options.openTargetName] = {
command: `cypress open`,
options: { cwd: projectRoot },
};

return { targets, targetGroups };
}

function normalizeOptions(options: CypressPluginOptions): CypressPluginOptions {
options ??= {};
options.targetName ??= 'e2e';
options.openTargetName ??= 'open-cypress';
options.componentTestingTargetName ??= 'component-test';
options.ciTargetName ??= 'e2e-ci';
return options;
Expand Down

0 comments on commit 99cfe51

Please sign in to comment.