Skip to content

Commit

Permalink
chore: Allow development under Windows platform (#992)
Browse files Browse the repository at this point in the history
This patch improves life of puppeteer contributor on Windows:

- Setting environment variables using cross-env since Windows requires the SET command.
- Calling Jasmine in the script debug-unit using jasmine's JavaScript binary instead of shell.
- Add /test/test-user-data-dir* to .gitignore since temporary user data directories, in case of test 
  fails, remains in the test directory.
  • Loading branch information
elisherer authored and aslushnikov committed Oct 11, 2017
1 parent ff08e45 commit 9ecf20f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1,5 +1,6 @@
/node_modules/
/test/output
/test/test-user-data-dir*
/.local-chromium/
/.dev_profile*
.DS_Store
Expand Down
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -9,13 +9,13 @@
},
"scripts": {
"unit": "jasmine test/test.js",
"debug-unit": "DEBUG_TEST=true node --inspect-brk ./node_modules/.bin/jasmine test/test.js",
"debug-unit": "cross-env DEBUG_TEST=true node --inspect-brk ./node_modules/jasmine/bin/jasmine.js test/test.js",
"test-doclint": "jasmine utils/doclint/check_public_api/test/test.js && jasmine utils/doclint/preprocessor/test.js",
"test": "npm run lint --silent && npm run coverage && npm run test-doclint && npm run test-node6-transformer",
"install": "node install.js",
"lint": "([ \"$CI\" = true ] && eslint --quiet -f codeframe . || eslint .) && npm run tsc && npm run doc",
"doc": "node utils/doclint/cli.js",
"coverage": "COVERAGE=true npm run unit",
"coverage": "cross-env COVERAGE=true npm run unit",
"test-node6-transformer": "jasmine utils/node6-transform/test/test.js",
"build": "node utils/node6-transform/index.js",
"unit-node6": "jasmine node6-test/test.js",
Expand Down Expand Up @@ -44,6 +44,7 @@
"@types/rimraf": "^2.0.2",
"@types/ws": "^3.0.2",
"commonmark": "^0.27.0",
"cross-env": "^5.0.5",
"eslint": "^4.0.0",
"esprima": "^4.0.0",
"jasmine": "^2.6.0",
Expand Down
9 changes: 7 additions & 2 deletions test/test.js
Expand Up @@ -38,6 +38,7 @@ const EMPTY_PAGE = PREFIX + '/empty.html';
const HTTPS_PORT = 8908;
const HTTPS_PREFIX = 'https://localhost:' + HTTPS_PORT;

const windows = /^win/.test(process.platform);
const headless = (process.env.HEADLESS || 'true').trim().toLowerCase() === 'true';
const slowMo = parseInt((process.env.SLOW_MO || '0').trim(), 10);
const executablePath = process.env.CHROME;
Expand Down Expand Up @@ -108,7 +109,9 @@ describe('Puppeteer', function() {
await puppeteer.launch(options).catch(e => waitError = e);
expect(waitError.message.startsWith('Failed to launch chrome! spawn random-invalid-path ENOENT')).toBe(true);
}));
it('userDataDir option', SX(async function() {
// Windows has issues running Chromium using a custom user data dir. It hangs when closing the browser.
// @see https://github.com/GoogleChrome/puppeteer/issues/918
(windows ? xit : it)('userDataDir option', SX(async function() {
const userDataDir = fs.mkdtempSync(path.join(__dirname, 'test-user-data-dir'));
const options = Object.assign({userDataDir}, defaultBrowserOptions);
const browser = await puppeteer.launch(options);
Expand All @@ -117,7 +120,9 @@ describe('Puppeteer', function() {
expect(fs.readdirSync(userDataDir).length).toBeGreaterThan(0);
rm(userDataDir);
}));
it('userDataDir argument', SX(async function() {
// Windows has issues running Chromium using a custom user data dir. It hangs when closing the browser.
// @see https://github.com/GoogleChrome/puppeteer/issues/918
(windows ? xit : it)('userDataDir argument', SX(async function() {
const userDataDir = fs.mkdtempSync(path.join(__dirname, 'test-user-data-dir'));
const options = Object.assign({}, defaultBrowserOptions);
options.args = [`--user-data-dir=${userDataDir}`].concat(options.args);
Expand Down

0 comments on commit 9ecf20f

Please sign in to comment.