From 7fa7e9e5db16be51a38aa9b42eecfcbac93230e4 Mon Sep 17 00:00:00 2001 From: Michael Withagen Date: Wed, 20 Feb 2019 18:37:19 +0100 Subject: [PATCH] fix(cypress task): Return error when tests fail Make au cypress --run emit error when a test failed to allow a build process/step to fail. Closes #1057 --- lib/resources/tasks/cypress.js | 7 +++++-- lib/resources/tasks/cypress.ts | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/resources/tasks/cypress.js b/lib/resources/tasks/cypress.js index 5efd5f614..9133bfe58 100644 --- a/lib/resources/tasks/cypress.js +++ b/lib/resources/tasks/cypress.js @@ -2,9 +2,12 @@ import cypress from 'cypress'; import { CLIOptions } from 'aurelia-cli'; import config from '../../cypress.config'; -export default () => { +export default (resolve) => { if (CLIOptions.hasFlag('run')) { - cypress.run(config); + cypress + .run(config) + .then(results => (results.totalFailed === 0 ? resolve() : resolve('Run failed!'))) + .catch(resolve); } else { cypress.open(config); } diff --git a/lib/resources/tasks/cypress.ts b/lib/resources/tasks/cypress.ts index e128638d1..7dee63b5e 100644 --- a/lib/resources/tasks/cypress.ts +++ b/lib/resources/tasks/cypress.ts @@ -2,9 +2,12 @@ import * as cypress from 'cypress'; import { CLIOptions } from 'aurelia-cli'; import * as config from '../../cypress.config'; -export default () => { +export default (resolve) => { if (CLIOptions.hasFlag('run')) { - cypress.run(config); + cypress + .run(config) + .then(results => (results.totalFailed === 0 ? resolve() : resolve('Run failed!'))) + .catch(resolve); } else { cypress.open(config); }