Introduce CHROME env variable for tests (#205)

This patch adds `CHROME` env variable which allows to
specify custom executable path to run tests.
This commit is contained in:
Andrey Lushnikov 2017-08-03 21:38:55 -07:00 committed by GitHub
parent a4c0d58204
commit 2d650d0301
2 changed files with 23 additions and 5 deletions

View File

@ -103,6 +103,10 @@ npm run unit -- --filter=waitFor
``` ```
HEADLESS=false npm run unit HEADLESS=false npm run unit
``` ```
- To run tests with custom chromium executable:
```
CHROME=<path-to-executable> npm run unit
```
- To run tests in slow-mode: - To run tests in slow-mode:
``` ```
HEADLESS=false SLOW_MO=500 npm run unit HEADLESS=false SLOW_MO=500 npm run unit

View File

@ -24,6 +24,9 @@ const Browser = require('../lib/Browser');
const SimpleServer = require('./server/SimpleServer'); const SimpleServer = require('./server/SimpleServer');
const GoldenUtils = require('./golden-utils'); const GoldenUtils = require('./golden-utils');
const YELLOW_COLOR = '\x1b[33m';
const RESET_COLOR = '\x1b[0m';
const GOLDEN_DIR = path.join(__dirname, 'golden'); const GOLDEN_DIR = path.join(__dirname, 'golden');
const OUTPUT_DIR = path.join(__dirname, 'output'); const OUTPUT_DIR = path.join(__dirname, 'output');
@ -33,11 +36,18 @@ const EMPTY_PAGE = PREFIX + '/empty.html';
const HTTPS_PORT = 8908; const HTTPS_PORT = 8908;
const HTTPS_PREFIX = 'https://localhost:' + HTTPS_PORT; const HTTPS_PREFIX = 'https://localhost:' + HTTPS_PORT;
const iPhone = require('../DeviceDescriptors')['iPhone 6'];
const iPhoneLandscape = require('../DeviceDescriptors')['iPhone 6 landscape'];
const headless = (process.env.HEADLESS || 'true').trim().toLowerCase() === 'true'; const headless = (process.env.HEADLESS || 'true').trim().toLowerCase() === 'true';
const slowMo = parseInt((process.env.SLOW_MO || '0').trim(), 10); const slowMo = parseInt((process.env.SLOW_MO || '0').trim(), 10);
const executablePath = process.env.CHROME;
if (executablePath)
console.warn(`${YELLOW_COLOR}WARN: running tests with ${executablePath}${RESET_COLOR}`);
const defaultBrowserOptions = {
executablePath,
slowMo,
headless,
args: ['--no-sandbox']
};
if (process.env.DEBUG_TEST || slowMo) if (process.env.DEBUG_TEST || slowMo)
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 1000 * 1000; jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 1000 * 1000;
@ -71,7 +81,8 @@ afterAll(SX(async function() {
describe('Browser', function() { describe('Browser', function() {
it('Browser.Options.ignoreHTTPSErrors', SX(async function() { it('Browser.Options.ignoreHTTPSErrors', SX(async function() {
let browser = new Browser({ignoreHTTPSErrors: true, headless, slowMo, args: ['--no-sandbox']}); let options = Object.assign({ignoreHTTPSErrors: true}, defaultBrowserOptions);
let browser = new Browser(options);
let page = await browser.newPage(); let page = await browser.newPage();
let error = null; let error = null;
let response = null; let response = null;
@ -87,11 +98,14 @@ describe('Browser', function() {
}); });
describe('Page', function() { describe('Page', function() {
const iPhone = require('../DeviceDescriptors')['iPhone 6'];
const iPhoneLandscape = require('../DeviceDescriptors')['iPhone 6 landscape'];
let browser; let browser;
let page; let page;
beforeAll(SX(async function() { beforeAll(SX(async function() {
browser = new Browser({headless, slowMo, args: ['--no-sandbox']}); browser = new Browser(defaultBrowserOptions);
})); }));
afterAll(SX(async function() { afterAll(SX(async function() {