Skip to content

Commit

Permalink
Adding headless chrome to known browser (#1294)
Browse files Browse the repository at this point in the history
  • Loading branch information
step2yeung authored and stefanpenner committed Sep 7, 2018
1 parent 9b8e70d commit 9c830d6
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
32 changes: 32 additions & 0 deletions lib/utils/known-browsers.js
Expand Up @@ -34,6 +34,16 @@ function chromeArgs(browserTmpDir, url) {
];
}

function headlessChromeArgs(browserTmpDir, url) {
return [
'--headless',
'--disable-gpu',
'--disable-software-rasterizer',
'--mute-audio',
'--remote-debugging-port=0',
'--window-size=1440,900'].concat(chromeArgs(browserTmpDir, url));
}

// Return the catalogue of the browsers that Testem supports for the platform. Each 'browser object'
// will contain these fields:
//
Expand Down Expand Up @@ -96,6 +106,18 @@ module.exports = function knownBrowsers(platform, config) {
return chromeArgs(this.browserTmpDir(), url);
}
},
{
name: 'Headless Chrome',
possiblePath: chromeWinPaths(userHomeDir, 'Chrome').concat(chromeOSXPaths('Google Chrome')),
possibleExe: [
'google-chrome',
'google-chrome-stable',
'chrome'
],
args(config, url) {
return headlessChromeArgs(this.browserTmpDir(), url);
}
},

// On Windows, Chrome Stable/Beta/Dev are installed on the same path
{
Expand All @@ -108,6 +130,16 @@ module.exports = function knownBrowsers(platform, config) {
return chromeArgs(this.browserTmpDir(), url);
}
},
{
name: 'Headless Chrome Beta',
possiblePath: chromeOSXPaths('Google Chrome Beta'),
possibleExe: [
'google-chrome-beta'
],
args(config, url) {
return headlessChromeArgs(this.browserTmpDir(), url);
}
},
{
name: 'Chrome Dev',
possiblePath: chromeOSXPaths('Google Chrome Dev'),
Expand Down
32 changes: 31 additions & 1 deletion tests/utils/known-browsers_tests.js
Expand Up @@ -189,7 +189,7 @@ describe('knownBrowsers', function() {
}

browsers = knownBrowsers('any', config);
chrome = findBrowser(browsers, 'Chrome');
chrome = findBrowser(browsers, browserName || 'Chrome');
}

beforeEach(function() {
Expand Down Expand Up @@ -283,6 +283,36 @@ describe('knownBrowsers', function() {
]);
});
});

describe('headless browser_args', function() {
beforeEach(function() {
setup('Headless Chrome');
});

afterEach(function() {
setup();
});

it('constructs correct args with browser_args', function() {
expect(chrome.args.call(launcher, config, url)).to.deep.eq([
'--testem',
'--headless',
'--disable-gpu',
'--disable-software-rasterizer',
'--mute-audio',
'--remote-debugging-port=0',
'--window-size=1440,900',
'--user-data-dir=' + browserTmpDir,
'--no-default-browser-check',
'--no-first-run',
'--ignore-certificate-errors',
'--test-type',
'--disable-renderer-backgrounding',
'--disable-background-timer-throttling',
url
]);
});
});
});

describe('Safari', function() {
Expand Down

0 comments on commit 9c830d6

Please sign in to comment.