Skip to content

Commit

Permalink
fix(e2e): return exit codes on failure of e2e tests
Browse files Browse the repository at this point in the history
Fix #1017
Close #1025
  • Loading branch information
marc-sensenich authored and filipesilva committed Jun 9, 2016
1 parent 901bad0 commit aad1709
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then source ~/.nvm/nvm-exec; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew tap caskroom/cask; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew cask install google-chrome; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew cask install google-chrome --force; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export DISPLAY=:99.0; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sh -e /etc/init.d/xvfb start; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CHROME_BIN=chromium-browser; fi
Expand Down
4 changes: 3 additions & 1 deletion addon/ng2/tasks/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ import {exec} from 'child_process';
module.exports = Task.extend({
run: function () {
var ui = this.ui;
var exitCode = 0;

return new Promise((resolve) => {
exec(`npm run e2e -- ${this.project.ngConfig.e2e.protractor.config}`, (err, stdout, stderr) => {
ui.writeLine(stdout);
if (err) {
ui.writeLine(stderr);
ui.writeLine(chalk.red('Some end-to-end tests failed, see above.'));
exitCode = err.code;
} else {
ui.writeLine(chalk.green('All end-to-end tests pass.'));
}
resolve();
resolve(exitCode);
});
});
}
Expand Down
25 changes: 25 additions & 0 deletions tests/e2e/e2e_workflow.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,27 @@ describe('Basic end-to-end Workflow', function () {
});
});

it('ng e2e fails with error exit code', function () {
this.timeout(240000);

function executor(resolve, reject) {
child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => {
console.log(stdout)
console.log(stderr)
if (error !== null) {
resolve(stderr);
} else {
reject(stdout);
}
});
}

return new Promise(executor)
.catch((msg) => {
throw new Error(msg);
});
});

it('Serve and run e2e tests after initial build', function () {
this.timeout(240000);

Expand All @@ -128,6 +149,8 @@ describe('Basic end-to-end Workflow', function () {
if (/Build successful/.test(data) && !startedProtractor) {
startedProtractor = true;
child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => {
console.log(stdout)
console.log(stderr)
if (error !== null) {
reject(stderr)
} else {
Expand Down Expand Up @@ -430,6 +453,8 @@ describe('Basic end-to-end Workflow', function () {
if (/Build successful/.test(data) && !startedProtractor) {
startedProtractor = true;
child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => {
console.log(stdout)
console.log(stderr)
if (error !== null) {
reject(stderr)
} else {
Expand Down

0 comments on commit aad1709

Please sign in to comment.