From 50c7de5000ddc2e8353736b2b0e554f4ac0d3cf7 Mon Sep 17 00:00:00 2001 From: Saeed Ganji Date: Fri, 16 Aug 2019 13:28:04 +0430 Subject: [PATCH] feat(cypress): update cypress to reflect changes for running with custom port & host --- .../cypress/aurelia_project/tasks/cypress.ext | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/skeleton/cypress/aurelia_project/tasks/cypress.ext b/skeleton/cypress/aurelia_project/tasks/cypress.ext index 847f2d5d6..472a991af 100644 --- a/skeleton/cypress/aurelia_project/tasks/cypress.ext +++ b/skeleton/cypress/aurelia_project/tasks/cypress.ext @@ -7,14 +7,37 @@ import * as cypress from 'cypress'; import * as config from '../../cypress.config'; // @endif import { CLIOptions } from 'aurelia-cli'; +import * as project from '../aurelia.json'; +import { default as runAppServer, shutdownAppServer } from './run'; -export default (cb) => { +const runCypress = (cb) => { if (CLIOptions.hasFlag('run')) { + const port = CLIOptions.getFlagValue('port') || project.platform.port; cypress .run(config) - .then(results => (results.totalFailed === 0 ? cb() : cb('Run failed!'))) + .then(results => { + if (results.totalFailed === 0) { + shutdownAppServer().then(cb); + } + else { + shutdownAppServer(1) + .then(_ => { + cb('Tests failed'); + }); + } + }) .catch(cb); } else { cypress.open(config); } +} + +export default (cb) => { + if (CLIOptions.hasFlag('start')) { + runCypress(cb); + runAppServer(); + return; + } + + runCypress(cb); };