Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-environment-puppeteer

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-environment-puppeteer - npm Package Compare versions

Comparing version 3.4.0 to 3.5.0

21

CHANGELOG.md

@@ -6,2 +6,19 @@ # Change Log

# [3.5.0](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/compare/v3.4.0...v3.5.0) (2018-11-04)
### Features
* add incognito context support ([#140](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/issues/140)) ([5b8983a](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/commit/5b8983a)), closes [#133](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/issues/133)
* disable tab throttling ([#144](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/issues/144)) ([b92e76c](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/commit/b92e76c)), closes [#137](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/issues/137)
### Performance Improvements
* remove lodash dependency ([#143](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/issues/143)) ([0cf7109](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/commit/0cf7109))
<a name="3.4.0"></a>

@@ -18,6 +35,2 @@ # [3.4.0](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/compare/v3.3.1...v3.4.0) (2018-09-24)

* **jest-environment-puppeteer:** Add ability to connect to an already existing instance of Chrome ([9de05f0](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/commit/9de05f0))
* **jest-environment-puppeteer:** Add documentation of new `connect `options ([c6b0613](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/commit/c6b0613))
* **jest-environment-puppeteer:** Remove unneeded async config ([30a3daa](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/commit/30a3daa))
* **jest-environment-puppeteer:** Simplify getBrowser function ([8ccb0d0](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/commit/8ccb0d0))
* connect to an already existing instance of Chrome ([#100](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/issues/100)) ([3fcbaf8](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer/commit/3fcbaf8))

@@ -24,0 +37,0 @@

@@ -52,4 +52,18 @@ "use strict";

}));
this.global.page = await this.global.browser.newPage();
if (config.browserContext === 'incognito') {
// Using this, pages will be created in a pristine context.
this.global.context = await this.global.browser.createIncognitoBrowserContext();
} else if (config.browserContext === 'default' || !config.browserContext) {
/**
* Since this is a new browser, browserContexts() will return only one instance
* https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#browserbrowsercontexts
*/
this.global.context = await this.global.browser.browserContexts()[0];
} else {
throw new Error(`browserContext should be either 'incognito' or 'default'. Received '${config.browserContext}'`);
}
this.global.page = await this.global.context.newPage();
if (config && config.exitOnPageError) {

@@ -105,4 +119,10 @@ this.global.page.addListener('pageerror', handleError);

async teardown() {
const config = await (0, _readConfig.default)();
this.global.page.removeListener('pageerror', handleError);
await this.global.page.close();
if (config.browserContext === 'incognito') {
await this.global.context.close();
} else {
await this.global.page.close();
}
}

@@ -109,0 +129,0 @@

14

lib/readConfig.js

@@ -14,3 +14,3 @@ "use strict";

var _lodash = require("lodash");
var _mergeDeep = _interopRequireDefault(require("merge-deep"));

@@ -22,10 +22,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

launch: {},
browserContext: 'default',
exitOnPageError: true
};
const DEFAULT_CONFIG_CI = {
const DEFAULT_CONFIG_CI = (0, _mergeDeep.default)(DEFAULT_CONFIG, {
launch: {
args: ['--no-sandbox', '--disable-setuid-sandbox']
},
exitOnPageError: true
};
args: ['--no-sandbox', '--disable-setuid-sandbox', '--disable-background-timer-throttling', '--disable-backgrounding-occluded-windows', '--disable-renderer-backgrounding']
}
});

@@ -52,3 +52,3 @@ async function readConfig() {

return (0, _lodash.merge)({}, defaultConfig, localConfig);
return (0, _mergeDeep.default)({}, defaultConfig, localConfig);
}

@@ -55,0 +55,0 @@

{
"name": "jest-environment-puppeteer",
"description": "Puppeteer environment for Jest.",
"version": "3.4.0",
"version": "3.5.0",
"main": "index.js",

@@ -24,3 +24,3 @@ "repository": "https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-environment-puppeteer",

"peerDependencies": {
"puppeteer": "^1.0.0"
"puppeteer": "^1.5.0"
},

@@ -30,6 +30,6 @@ "dependencies": {

"cwd": "^0.10.0",
"jest-dev-server": "^3.4.0",
"lodash": "^4.17.11"
"jest-dev-server": "^3.5.0",
"merge-deep": "^3.0.2"
},
"gitHead": "5c014f28a9a67b765dcc468471bc23a437903b18"
"gitHead": "8e41ec8e8c2bf3a8fbfc72a003940800b4fabc62"
}

@@ -63,2 +63,6 @@ # jest-environment-puppeteer

### `global.context`
Give access to a [browser context](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#class-browsercontext) that is instantiated when the browser is launched. You can control whether each test has its own isolated browser context using the `browserContext` option in your `jest-puppeteer.config.js`.
### `global.jestPuppeteer.debug()`

@@ -83,2 +87,5 @@

- `connect` <[object]> [All Puppeteer connect options](https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerconnectoptions) can be specified in config. This is an alternative to `launch` config, allowing you to connect to an already running instance of Chrome.
- `browserContext` <[string]>. By default, the browser context (cookies, localStorage, etc) is shared between all tests. The following options are available for `browserContext`:
- `default` Each test starts a tab, so all tests share the same context.
- `incognito` Each tests starts an incognito window, so all tests have a separate, isolated context. Useful when running tests that could interfere with one another. (*Example: testing multiple users on the same app at once with login, transactions, etc.*)
- `exitOnPageError` <[boolean]> Exits page on any global error message thrown. Defaults to `true`.

@@ -85,0 +92,0 @@ - `server` <[Object]> Server options allowed by [jest-dev-server](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-dev-server)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc