fix: Pass --no-sandbox chrome CLI option when running the integration tests on travis (#85)

This commit is contained in:
Luca Greco 2018-01-09 17:49:56 +01:00 committed by GitHub
parent 13d0ced89e
commit 94efb908b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 12 deletions

View File

@ -14,7 +14,7 @@ script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- echo "RUN integration tests on chrome" &&
./test/run-chrome-smoketests.sh
TRAVIS_CI=true ./test/run-chrome-smoketests.sh
after_script: npm run publish-coverage

View File

@ -1,6 +1,7 @@
const finalhandler = require("finalhandler");
const http = require("http");
const serveStatic = require("serve-static");
const puppeteer = require("puppeteer");
exports.createHTTPServer = async (path) => {
var serve = serveStatic(path);
@ -19,3 +20,25 @@ exports.createHTTPServer = async (path) => {
});
});
};
exports.launchPuppeteer = async (puppeteerArgs) => {
if (!puppeteerArgs || !Array.isArray(puppeteerArgs)) {
throw new Error(`Invalid puppeteer arguments: ${JSON.stringify(puppeteerArgs)}`);
}
const args = [].concat(puppeteerArgs);
// Pass the --no-sandbox chrome CLI option when running the integration tests
// on Travis.
if (process.env.TRAVIS_CI) {
args.push("--no-sandbox");
}
return puppeteer.launch({
// Chrome Extensions are not currently supported in headless mode.
headless: false,
// Custom chrome arguments.
args,
});
};

View File

@ -4,9 +4,8 @@ const path = require("path");
const waitUntil = require("async-wait-until");
const {deepEqual} = require("chai").assert;
const puppeteer = require("puppeteer");
const {createHTTPServer} = require("./setup");
const {createHTTPServer, launchPuppeteer} = require("./setup");
const fixtureExtensionDirName = "runtime-messaging-extension";
@ -20,15 +19,9 @@ describe("browser.runtime.onMessage/sendMessage", function() {
const url = `http://localhost:${server.address().port}`;
const browser = await puppeteer.launch({
// Chrome Extensions are not currently supported in headless mode.
headless: false,
// Custom chrome arguments.
args: [
`--load-extension=${process.env.TEST_EXTENSIONS_PATH}/${fixtureExtensionDirName}`,
],
});
const browser = await launchPuppeteer([
`--load-extension=${process.env.TEST_EXTENSIONS_PATH}/${fixtureExtensionDirName}`,
]);
const page = await browser.newPage();