jest-environment-puppeteer
Advanced tools
Comparing version 2.3.0 to 2.4.0
@@ -6,2 +6,15 @@ # Change Log | ||
<a name="2.4.0"></a> | ||
# [2.4.0](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/compare/v2.3.0...v2.4.0) (2018-04-24) | ||
### Features | ||
* adjust default timeout with slowMo ([6871ec8](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/commit/6871ec8)), closes [#36](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/issues/36) | ||
* **jest-environment-puppeteer:** add server.launchTimeout & server.debug options ([e312717](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/commit/e312717)), closes [#44](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/issues/44) | ||
* **jest-environment-puppeteer:** added config option for global err msg ([#35](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/issues/35)) ([d87c99a](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/commit/d87c99a)), closes [#34](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/issues/34) | ||
<a name="2.3.0"></a> | ||
@@ -8,0 +21,0 @@ # [2.3.0](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/compare/v2.2.3...v2.3.0) (2018-04-06) |
@@ -10,2 +10,6 @@ 'use strict'; | ||
var _stream = require('stream'); | ||
var _stream2 = _interopRequireDefault(_stream); | ||
var _fs = require('fs'); | ||
@@ -39,2 +43,6 @@ | ||
var _chalk = require('chalk'); | ||
var _chalk2 = _interopRequireDefault(_chalk); | ||
var _readConfig = require('./readConfig'); | ||
@@ -51,2 +59,9 @@ | ||
const serverLogPrefixer = new _stream2.default.Transform({ | ||
transform(chunk, encoding, callback) { | ||
this.push(_chalk2.default.magentaBright(`[Jest Puppeteer server] ${chunk.toString()}`)); | ||
callback(); | ||
} | ||
}); | ||
async function setup() { | ||
@@ -65,4 +80,19 @@ const config = await (0, _readConfig2.default)(); | ||
if (config.server.debug) { | ||
console.log(_chalk2.default.magentaBright('\nJest Puppeteer server output:')); | ||
server.stdout.pipe(serverLogPrefixer).pipe(process.stdout); | ||
} | ||
if (config.server.port) { | ||
await (0, _waitPort2.default)({ port: config.server.port, output: 'silent' }); | ||
const launchTimeout = config.server.launchTimeout || 5000; | ||
const timeout = setTimeout(() => { | ||
console.error(_chalk2.default.red(`\nJest Puppeteer Error: Server has taken more than ${launchTimeout}ms to start.`)); | ||
console.error(_chalk2.default.blue(`You can set "server.launchTimeout" in jest-puppeteer.config.js`)); | ||
process.exit(1); | ||
}, launchTimeout); | ||
await (0, _waitPort2.default)({ | ||
port: config.server.port, | ||
output: 'silent' | ||
}); | ||
clearTimeout(timeout); | ||
} | ||
@@ -69,0 +99,0 @@ } |
@@ -32,2 +32,4 @@ 'use strict'; | ||
const config = await (0, _readConfig2.default)(); | ||
this.global.puppeteerConfig = config; | ||
const wsEndpoint = _fs2.default.readFileSync(_constants.WS_ENDPOINT_PATH, 'utf8'); | ||
@@ -43,3 +45,5 @@ if (!wsEndpoint) { | ||
this.global.page = await this.global.browser.newPage(); | ||
this.global.page.addListener('pageerror', handleError); | ||
if (config && config.exitOnPageError) { | ||
this.global.page.addListener('pageerror', handleError); | ||
} | ||
} | ||
@@ -46,0 +50,0 @@ |
@@ -26,3 +26,4 @@ 'use strict'; | ||
const DEFAULT_CONFIG = { | ||
launch: {} | ||
launch: {}, | ||
exitOnPageError: true | ||
}; | ||
@@ -32,3 +33,4 @@ const DEFAULT_CONFIG_CI = { | ||
args: ['--no-sandbox', '--disable-setuid-sandbox'] | ||
} | ||
}, | ||
exitOnPageError: true | ||
}; | ||
@@ -35,0 +37,0 @@ |
{ | ||
"name": "jest-environment-puppeteer", | ||
"description": "Puppeteer environment for Jest.", | ||
"version": "2.3.0", | ||
"version": "2.4.0", | ||
"main": "index.js", | ||
@@ -28,2 +28,3 @@ "repository": "https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer", | ||
"dependencies": { | ||
"chalk": "^2.4.0", | ||
"cwd": "^0.10.0", | ||
@@ -30,0 +31,0 @@ "lodash": "^4.17.5", |
@@ -68,6 +68,9 @@ # jest-environment-puppeteer | ||
* `launch` <[object]> [All Puppeteer launch options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions) can be specified in config. Since it is JavaScript, you can use all stuff you need, including environment. | ||
* `exitOnPageError` <[boolean]> Exits page on any global error message thrown. Defaults to `true`. | ||
* `server` <[Object]> Server options | ||
* `command` <[string]> Command to start server | ||
* `port` <[number]> If specified, it will wait port to be listened | ||
* `launchTimeout` <[number]> Maximum time in milliseconds to wait before the port is listened. Defaults to `5000`. | ||
* `options` <[Object]> Optional options for [spawnd](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/spawnd/README.md) | ||
* `debug` <[boolean]> Output server logs | ||
@@ -84,2 +87,4 @@ ```js | ||
port: 4444, | ||
launchTimeout: 10000, | ||
debug: true, | ||
}, | ||
@@ -86,0 +91,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16289
159
106
9
+ Addedchalk@^2.4.0