Skip to content

Commit

Permalink
Introduce CHROME env variable for tests (puppeteer#205)
Browse files Browse the repository at this point in the history
This patch adds `CHROME` env variable which allows to
specify custom executable path to run tests.
  • Loading branch information
aslushnikov authored Aug 4, 2017
1 parent a4c0d58 commit 2d650d0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ npm run unit -- --filter=waitFor
```
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:
```
HEADLESS=false SLOW_MO=500 npm run unit
Expand Down
24 changes: 19 additions & 5 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const Browser = require('../lib/Browser');
const SimpleServer = require('./server/SimpleServer');
const GoldenUtils = require('./golden-utils');

const YELLOW_COLOR = '\x1b[33m';
const RESET_COLOR = '\x1b[0m';

const GOLDEN_DIR = path.join(__dirname, 'golden');
const OUTPUT_DIR = path.join(__dirname, 'output');

Expand All @@ -33,11 +36,18 @@ const EMPTY_PAGE = PREFIX + '/empty.html';
const HTTPS_PORT = 8908;
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 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)
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000 * 1000 * 1000;
Expand Down Expand Up @@ -71,7 +81,8 @@ afterAll(SX(async function() {

describe('Browser', 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 error = null;
let response = null;
Expand All @@ -87,11 +98,14 @@ describe('Browser', function() {
});

describe('Page', function() {
const iPhone = require('../DeviceDescriptors')['iPhone 6'];
const iPhoneLandscape = require('../DeviceDescriptors')['iPhone 6 landscape'];

let browser;
let page;

beforeAll(SX(async function() {
browser = new Browser({headless, slowMo, args: ['--no-sandbox']});
browser = new Browser(defaultBrowserOptions);
}));

afterAll(SX(async function() {
Expand Down

0 comments on commit 2d650d0

Please sign in to comment.