Skip to content

Commit 7a6ba87

Browse files
committed
ci: use headless chrome on travis
1 parent 861b32b commit 7a6ba87

File tree

5 files changed

+53
-27
lines changed

5 files changed

+53
-27
lines changed

.travis.yml

-3
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ matrix:
9292

9393

9494
before_install:
95-
# Use a virtual display.
96-
- export DISPLAY=:99.0
97-
- sh -e /etc/init.d/xvfb start
9895
# Install yarn.
9996
- curl -o- -L https://yarnpkg.com/install.sh | bash
10097
- export PATH="$HOME/.yarn/bin:$PATH"

tests/e2e/assets/1.0.0-proj/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"jasmine-core": "~2.5.2",
3434
"jasmine-spec-reporter": "~3.2.0",
3535
"karma": "~1.4.1",
36-
"karma-chrome-launcher": "~2.0.0",
36+
"karma-chrome-launcher": "~2.1.1",
3737
"karma-cli": "~1.0.1",
3838
"karma-jasmine": "~1.1.0",
3939
"karma-jasmine-html-reporter": "^0.2.2",

tests/e2e/setup/500-create-project.ts

+2-22
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {join} from 'path';
22
import {git, ng, silentNpm} from '../utils/process';
33
import {expectFileToExist, replaceInFile} from '../utils/fs';
4-
import {updateTsConfig, updateJsonFile, useNg2} from '../utils/project';
4+
import {updateTsConfig, updateJsonFile, useNg2, useCIChrome} from '../utils/project';
55
import {gitClean, gitCommit} from '../utils/git';
66
import {getGlobalVariable} from '../utils/env';
77

@@ -36,27 +36,7 @@ export default function() {
3636
json['dependencies'][pkgName] = packages[pkgName].tar;
3737
});
3838
}))
39-
// There's a race condition happening in Chrome. Enabling logging in chrome used by
40-
// protractor actually fixes it. Logging is piped to a file so it doesn't affect our setup.
41-
// --no-sandbox is needed for Circle CI.
42-
.then(() => replaceInFile('protractor.conf.js', `'browserName': 'chrome'`,
43-
`'browserName': 'chrome',
44-
chromeOptions: {
45-
args: [
46-
"--enable-logging",
47-
"--no-sandbox",
48-
]
49-
}
50-
`))
51-
.then(() => replaceInFile('karma.conf.js', `browsers: ['Chrome'],`,
52-
`browsers: ['ChromeNoSandbox'],
53-
customLaunchers: {
54-
ChromeNoSandbox: {
55-
base: 'Chrome',
56-
flags: ['--no-sandbox']
57-
}
58-
},
59-
`))
39+
.then(() => useCIChrome())
6040
.then(() => argv['ng2'] ? useNg2() : Promise.resolve())
6141
.then(() => {
6242
if (argv['nightly'] || argv['ng-sha']) {

tests/e2e/tests/misc/breaking-change.ts

+21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createProjectFromAsset } from '../../utils/assets';
2+
import { replaceInFile } from '../../utils/fs';
23
import { ng } from '../../utils/process';
34

45
// This test ensures a project generated with 1.0.0 will still work.
@@ -7,6 +8,26 @@ import { ng } from '../../utils/process';
78
export default function () {
89
return Promise.resolve()
910
.then(() => createProjectFromAsset('1.0.0-proj'))
11+
// Update chrome configs.
12+
.then(() => replaceInFile('protractor.conf.js', `'browserName': 'chrome'`,
13+
`'browserName': 'chrome',
14+
chromeOptions: {
15+
args: [
16+
"--enable-logging",
17+
"--no-sandbox",
18+
${process.env['TRAVIS'] ? '"--headless", "--disable-gpu"' : ''}
19+
]
20+
}
21+
`))
22+
.then(() => replaceInFile('karma.conf.js', `browsers: ['Chrome'],`,
23+
`browsers: ['ChromeCI'],
24+
customLaunchers: {
25+
ChromeCI: {
26+
base: '${process.env['TRAVIS'] ? 'ChromeHeadless' : 'Chrome'}',
27+
flags: ['--no-sandbox']
28+
}
29+
},
30+
`))
1031
.then(() => ng('generate', 'component', 'my-comp'))
1132
.then(() => ng('lint'))
1233
.then(() => ng('test', '--single-run'))

tests/e2e/utils/project.ts

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {readFile, writeFile} from './fs';
1+
import {readFile, writeFile, replaceInFile} from './fs';
22
import {execAndWaitForOutputToMatch, silentNpm, ng} from './process';
33
import {getGlobalVariable} from './env';
44

@@ -43,6 +43,7 @@ export function createProject(name: string, ...args: string[]) {
4343
json['dependencies'][pkgName] = packages[pkgName].dist;
4444
});
4545
}))
46+
.then(() => useCIChrome())
4647
.then(() => argv['ng2'] ? useNg2() : Promise.resolve())
4748
.then(() => {
4849
if (argv.nightly || argv['ng-sha']) {
@@ -77,6 +78,33 @@ export function createProject(name: string, ...args: string[]) {
7778
.then(() => silentNpm('install'));
7879
}
7980

81+
export function useCIChrome() {
82+
// There's a race condition happening in Chrome. Enabling logging in chrome used by
83+
// protractor actually fixes it. Logging is piped to a file so it doesn't affect our setup.
84+
// --no-sandbox is needed for Circle CI.
85+
// Travis can use headless chrome, but not appveyor.
86+
return Promise.resolve()
87+
.then(() => replaceInFile('protractor.conf.js', `'browserName': 'chrome'`,
88+
`'browserName': 'chrome',
89+
chromeOptions: {
90+
args: [
91+
"--enable-logging",
92+
"--no-sandbox",
93+
${process.env['TRAVIS'] ? '"--headless", "--disable-gpu"' : ''}
94+
]
95+
}
96+
`))
97+
.then(() => replaceInFile('karma.conf.js', `browsers: ['Chrome'],`,
98+
`browsers: ['ChromeCI'],
99+
customLaunchers: {
100+
ChromeCI: {
101+
base: '${process.env['TRAVIS'] ? 'ChromeHeadless' : 'Chrome'}',
102+
flags: ['--no-sandbox']
103+
}
104+
},
105+
`));
106+
}
107+
80108
// Convert a Angular 4 project to Angular 2.
81109
export function useNg2() {
82110
const ng2Deps: any = {

0 commit comments

Comments
 (0)