Skip to content

Commit

Permalink
fix: cypress failure detection
Browse files Browse the repository at this point in the history
  • Loading branch information
sampullman committed Mar 17, 2023
1 parent d3ef588 commit 30855a8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
16 changes: 5 additions & 11 deletions packages/vue3-vite/generators.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,25 @@
{
"$schema": "http://json-schema.org/schema",
"name": "nx-vue3-vite",
"version": "0.23.7",
"version": "0.23.8",
"generators": {
"vue3-vite": {
"factory": "./src/generators/vue3-vite/generator",
"schema": "./src/generators/vue3-vite/schema.json",
"description": "vue3-vite generator",
"aliases": [
"app"
]
"aliases": ["app"]
},
"library": {
"factory": "./src/generators/library/generator",
"schema": "./src/generators/library/schema.json",
"description": "vue3-vite library generator",
"aliases": [
"lib"
]
"aliases": ["lib"]
},
"component": {
"factory": "./src/generators/component/generator",
"schema": "./src/generators/component/schema.json",
"description": "component generator",
"aliases": [
"c"
]
"aliases": ["c"]
},
"docs": {
"factory": "./src/generators/docs/generator",
Expand All @@ -38,4 +32,4 @@
"description": "vue3-vite cypress generator"
}
}
}
}
4 changes: 2 additions & 2 deletions packages/vue3-vite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nx-vue3-vite",
"version": "0.23.7",
"version": "0.23.8",
"main": "src/index.js",
"generators": "./generators.json",
"executors": "./executors.json",
Expand All @@ -21,4 +21,4 @@
"vite",
"generator"
]
}
}
14 changes: 9 additions & 5 deletions packages/vue3-vite/src/executors/cypress/executor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,19 @@ async function runCypress(baseUrl: string, opts: CypressExecutorOptions) {
* working. Forcing the build to success when `cypress.open` is used.
*/
if (opts.headless) {
const result = await Cypress.run(options);
const success = result.status === 'finished';
const failures = success ? 0 : result.failures;
const message = success ? '' : `, ${result.message}`;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const result = (await Cypress.run(options)) as any;
delete result.runs;

const finished = result.status === 'finished';
const failures = finished ? 0 : result.totalFailed;
const message = finished ? '' : `, ${result.message}`;

logger.info(JSON.stringify(result));
logger.info(
`Cypress completed with status: ${result.status}${message} failed=${failures}`
);
return success && failures <= 0;
return failures <= 0;
} else {
await Cypress.open(options);
return true;
Expand Down

0 comments on commit 30855a8

Please sign in to comment.