From 9ecf20fc032d03ea1aa855ee1d350ac21885988a Mon Sep 17 00:00:00 2001 From: Eli Sherer Date: Wed, 11 Oct 2017 22:14:13 +0300 Subject: [PATCH] chore: Allow development under Windows platform (#992) 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. --- .gitignore | 1 + package.json | 5 +++-- test/test.js | 9 +++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 38cb03633f392..e9c7f3851a925 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /node_modules/ /test/output +/test/test-user-data-dir* /.local-chromium/ /.dev_profile* .DS_Store diff --git a/package.json b/package.json index 123f736e6f583..08e44b100765d 100644 --- a/package.json +++ b/package.json @@ -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", @@ -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", diff --git a/test/test.js b/test/test.js index 62bfe734d488a..88d4f67a4669f 100644 --- a/test/test.js +++ b/test/test.js @@ -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; @@ -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); @@ -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);