Skip to content

Commit 794188b

Browse files
committed
debugging
1 parent d650428 commit 794188b

File tree

4 files changed

+68
-34
lines changed

4 files changed

+68
-34
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
sudo: false
1+
dist: trusty
2+
sudo: required
23
env:
34
- NODE_VERSION=5 SCRIPT=lint
45
- NODE_VERSION=5 SCRIPT=test

addon/ng2/blueprints/ng2/files/config/protractor.conf.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ exports.config = {
77
'../e2e/**/*.e2e.ts'
88
],
99
capabilities: {
10-
'browserName': 'chrome'
10+
'browserName': 'chrome',
11+
// 'chromeOptions': {
12+
// args: ['--no-sandbox']
13+
// }
1114
},
1215
directConnect: true,
1316
baseUrl: 'http://localhost:4200/',

addon/ng2/tasks/e2e.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ module.exports = Task.extend({
88
var ui = this.ui;
99

1010
return new Promise((resolve) => {
11-
exec(`npm run e2e -- ${this.project.ngConfig.e2e.protractor.config}`, (err, stdout) => {
11+
exec(`npm run e2e -- ${this.project.ngConfig.e2e.protractor.config}`, (err, stdout, stderr) => {
1212
ui.writeLine(stdout);
1313
if (err) {
14+
ui.writeLine(stderr);
1415
ui.writeLine(chalk.red('Some end-to-end tests failed, see above.'));
1516
} else {
1617
ui.writeLine(chalk.green('All end-to-end tests pass.'));

tests/e2e/e2e_workflow.spec.js

Lines changed: 60 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ var conf = require('ember-cli/tests/helpers/conf');
99
var sh = require('shelljs');
1010
var treeKill = require('tree-kill');
1111
var child_process = require('child_process');
12-
var Promise = require('ember-cli/lib/ext/promise');
13-
var execPromise = Promise.denodeify(child_process.exec);
1412
var ng = require('../helpers/ng');
1513
var root = path.join(process.cwd(), 'tmp');
1614

@@ -64,12 +62,12 @@ describe('Basic end-to-end Workflow', function () {
6462
sh.exec('npm install');
6563
});
6664

67-
it('Supports production builds via `ng build --environment=production`', function() {
65+
it('Supports production builds via `ng build -prod`', function() {
6866
this.timeout(420000);
6967

70-
// Can't user the `ng` helper because somewhere the environment gets
68+
// Can't use the `ng` helper because somewhere the environment gets
7169
// stuck to the first build done
72-
sh.exec(`${ngBin} build --environment=production`);
70+
sh.exec(`${ngBin} build -prod`);
7371
expect(existsSync(path.join(process.cwd(), 'dist'))).to.be.equal(true);
7472
var appBundlePath = path.join(process.cwd(), 'dist', 'app', 'index.js');
7573
var appBundleContent = fs.readFileSync(appBundlePath, { encoding: 'utf8' });
@@ -120,26 +118,36 @@ describe('Basic end-to-end Workflow', function () {
120118
});
121119

122120
it('Serve and run e2e tests after initial build', function () {
123-
this.timeout(420000);
121+
this.timeout(240000);
124122

125123
var ngServePid;
126124

127125
function executor(resolve, reject) {
128-
var serveFailedMsg = 'ng serve command failed';
129-
var e2eFailedMsg = 'ng serve command failed';
130-
var child = child_process.exec('ng serve');
131-
ngServePid = child.pid;
132-
133-
child.stdout.on('data', (data) => {
134-
if (/^Build successful/.test(data)) {
135-
resolve(execPromise('ng e2e').catch(() => Promise.reject(e2eFailedMsg)));
126+
var serveProcess = child_process.exec(`${ngBin} serve`);
127+
var startedProtractor = false;
128+
ngServePid = serveProcess.pid;
129+
130+
serveProcess.stdout.on('data', (data) => {
131+
if (/Build successful/.test(data) && !startedProtractor) {
132+
startedProtractor = true;
133+
child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => {
134+
if (error !== null) {
135+
reject(stderr)
136+
} else {
137+
resolve();
138+
}
139+
});
136140
} else if (/ failed with:/.test(data)) {
137-
reject(serveFailedMsg);
141+
reject(data);
138142
}
139143
});
140144

141-
child.stderr.on('data', () => reject(serveFailedMsg));
142-
child.on('close', (code) => code === 0 ? resolve() : reject(serveFailedMsg));
145+
serveProcess.stderr.on('data', (data) => {
146+
reject(data);
147+
});
148+
serveProcess.on('close', (code) => {
149+
code === 0 ? resolve() : reject('ng serve command closed with error')
150+
});
143151
}
144152

145153
return new Promise(executor)
@@ -410,28 +418,38 @@ describe('Basic end-to-end Workflow', function () {
410418
expect('build failed where it should have succeeded').to.equal('');
411419
});
412420
});
413-
414-
it('Serve and run e2e tests after final build', function () {
415-
this.timeout(420000);
421+
422+
it('Serve and run e2e tests after all other commands', function () {
423+
this.timeout(240000);
416424

417425
var ngServePid;
418426

419427
function executor(resolve, reject) {
420-
var serveFailedMsg = 'ng serve command failed';
421-
var e2eFailedMsg = 'ng serve command failed';
422-
var child = child_process.exec(`${ngBin} serve`);
423-
ngServePid = child.pid;
424-
425-
child.stdout.on('data', (data) => {
426-
if (/^Build successful/.test(data)) {
427-
resolve(execPromise(`${ngBin} e2e`).catch(() => Promise.reject(e2eFailedMsg)));
428+
var serveProcess = child_process.exec(`${ngBin} serve`);
429+
var startedProtractor = false;
430+
ngServePid = serveProcess.pid;
431+
432+
serveProcess.stdout.on('data', (data) => {
433+
if (/Build successful/.test(data) && !startedProtractor) {
434+
startedProtractor = true;
435+
child_process.exec(`${ngBin} e2e`, (error, stdout, stderr) => {
436+
if (error !== null) {
437+
reject(stderr)
438+
} else {
439+
resolve();
440+
}
441+
});
428442
} else if (/ failed with:/.test(data)) {
429-
reject(serveFailedMsg);
443+
reject(data);
430444
}
431445
});
432446

433-
child.stderr.on('data', () => reject(serveFailedMsg));
434-
child.on('close', (code) => code === 0 ? resolve() : reject(serveFailedMsg));
447+
serveProcess.stderr.on('data', (data) => {
448+
reject(data);
449+
});
450+
serveProcess.on('close', (code) => {
451+
code === 0 ? resolve() : reject('ng serve command closed with error')
452+
});
435453
}
436454

437455
return new Promise(executor)
@@ -443,4 +461,15 @@ describe('Basic end-to-end Workflow', function () {
443461
throw new Error(msg);
444462
});
445463
});
464+
465+
it('Still Supports production builds after all other commands`', function() {
466+
this.timeout(420000);
467+
468+
sh.exec(`${ngBin} build -prod`);
469+
expect(existsSync(path.join(process.cwd(), 'dist'))).to.be.equal(true);
470+
var appBundlePath = path.join(process.cwd(), 'dist', 'app', 'index.js');
471+
var appBundleContent = fs.readFileSync(appBundlePath, { encoding: 'utf8' });
472+
expect(appBundleContent).to.include('production:!0');
473+
expect(sh.exec('git status --porcelain').output).to.be.equal(undefined);
474+
});
446475
});

0 commit comments

Comments
 (0)