10000 fix(e2e): return exit codes on failure of e2e tests · Madd/angular-cli@d0c07ac · GitHub
[go: up one dir, main page]

Skip to content

Commit d0c07ac

Browse files
marc-sensenichfilipesilva
authored andcommitted
fix(e2e): return exit codes on failure of e2e tests
Fix angular#1017 Close angular#1025 Close angular#1044
1 parent 901bad0 commit d0c07ac

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ before_install:
1919
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then source ~/.nvm/nvm-exec; fi
2020
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
2121
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew tap caskroom/cask; fi
22-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew cask install google-chrome; fi
22+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew cask install google-chrome --force; fi
2323
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export DISPLAY=:99.0; fi
2424
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sh -e /etc/init.d/xvfb start; fi
2525
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then export CHROME_BIN=chromium-browser; fi

addon/ng2/blueprints/ng2/files/e2e/app.e2e-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ describe('<%= htmlComponentName %> App', function() {
99

1010
it('should display message saying app works', () => {
1111
page.navigateTo();
12-
expect(page.getParagraphText()).toEqual('<%= htmlComponentName %> works!');
12+
expect(page.getParagraphText()).toEqual('<%= prefix %> works!');
1313
});
1414
});

addon/ng2/blueprints/ng2/files/e2e/app.po.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ export class <%= jsComponentName %>Page {
44
}
55

66
getParagraphText() {
7-
return element(by.css('<%= htmlComponentName %>-app h1')).getText();
7+
return element(by.css('<%= prefix %>-root h1')).getText();
88
}
99
}

addon/ng2/tasks/e2e.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@ import {exec} from 'child_process';
66
module.exports = Task.extend({
77
run: function () {
88
var ui = this.ui;
9+
var exitCode = 0;
910

1011
return new Promise((resolve) => {
1112
exec(`npm run e2e -- ${this.project.ngConfig.e2e.protractor.config}`, (err, stdout, stderr) => {
1213
ui.writeLine(stdout);
1314
if (err) {
1415
ui.writeLine(stderr);
1516
ui.writeLine(chalk.red('Some end-to-end tests failed, see above.'));
17+
exitCode = err.code;
1618
} else {
1719
ui.writeLine(chalk.green('All end-to-end tests pass.'));
1820
}
19-
resolve();
21+
resolve(exitCode);
2022
});
2123
});
2224
}

tests/e2e/e2e_workflow.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,25 @@ describe('Basic end-to-end Workflow', function () {
114114
});
115115
});
116116

117+
it('ng e2e fails with error exit code', function () {
118+
this.timeout(240000);
119+
120+
function executor(resolve, reject) {
121+
child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => {
122+
if (error !== null) {
123+
resolve(stderr);
124+
} else {
125+
reject(stdout);
126+
}
127+
});
128+
}
129+
130+
return new Promise(executor)
131+
.catch((msg) => {
132+
throw new Error(msg);
133+
});
134+
});
135+
117136
it('Serve and run e2e tests after initial build', function () {
118137
this.timeout(240000);
119138

0 commit comments

Comments
 (0)
0