Skip to content

Commit

Permalink
fix(plugin): replace old browser args with a new launch options (#32)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: The `ensureRequiredBrowserFlags` method is no longer supported. It was renamed the `ensureBrowserFlags` and now it accepts the second argument as an [options](cypress-io/cypress#6306) object with an args property instead of an array of browser arguments.

Before:

```js
// cypress/plugins/index.js

const { install, ensureRequiredBrowserFlags } = require('@neuralegion/cypress-har-generator');

module.exports = (on, config) => {
  install(on, config);

  on('before:browser:launch', (browser = {}, args) =>
    ensureRequiredBrowserFlags(browser, args)
  );
};
```

After:

```js
// cypress/plugins/index.js

const { install, ensureBrowserFlags } = require('@neuralegion/cypress-har-generator');

module.exports = (on, config) => {
  install(on, config);

  on('before:browser:launch', (browser = {}, launchOptions) => {
    ensureBrowserFlags(browser, launchOptions);
    return launchOptions;
  });
};
```

closes #31
  • Loading branch information
derevnjuk authored Feb 18, 2020
1 parent 1940552 commit e437e87
Show file tree
Hide file tree
Showing 15 changed files with 3,764 additions and 5,325 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ npm i --save-dev @neuralegion/cypress-har-generator
Next, go to the cypress's directory and put this code is in your `cypress/plugins/index.js` file:

```js
const { install, ensureRequiredBrowserFlags } = require('@neuralegion/cypress-har-generator');
const { install, ensureBrowserFlags } = require('@neuralegion/cypress-har-generator');

module.exports = (on, config) => {
install(on, config);

on('before:browser:launch', (browser = {}, args) =>
ensureRequiredBrowserFlags(browser, args)
);
on('before:browser:launch', (browser = {}, launchOptions) => {
ensureBrowserFlags(browser, launchOptions);
return launchOptions;
});
};
```

Expand Down
4 changes: 2 additions & 2 deletions example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ You can find test files in [cypress/integration](cypress/integration) folder.

## Install

Run `npm i` to install dependencies.
Run `npm ci` to install dependencies.


## How to run

Run `npm run test` to trigger tests and run recording.
Run `npm test` to trigger tests and run recording.
9 changes: 4 additions & 5 deletions example/cypress/plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const { install, ensureRequiredBrowserFlags } = require('../../../dist');
const { install, ensureBrowserFlags } = require('../../../dist');

module.exports = (on) => {
install(on);

on('before:browser:launch', (browser = {}, args) => {
args = ensureRequiredBrowserFlags(browser, args);
args.push('--headless');
return args;
on('before:browser:launch', (browser = {}, launchOptions) => {
ensureBrowserFlags(browser, launchOptions);
return launchOptions;
});
};
Loading

0 comments on commit e437e87

Please sign in to comment.