cypress-browser-extension-plugin
cypress-browser-extension-plugin copied to clipboard
Support Cypress v4
Hey, first of all, thx for amazing work on this plugin 👏
Cypress changed before:browser:launch
hook in v4, this will make it work
https://github.com/cypress-io/cypress/pull/6293
Another approach would be to use the following section in cypress/plugins/index.js
const extensionLoader = require('cypress-browser-extension-plugin/loader');
on('before:browser:launch', (browser = {}, launchOptions) => {
const onBeforeBrowserLaunch = extensionLoader.load({
source: '/path/to/myext',
skipHooks: true,
});
// explicit call to "browserArgs function" returned by the extensionLoader.load() as we need to
// translate the return value for compatibility with Cypress 4.x
var args = [...launchOptions.args]; // make copy of given args to avoid changing the original array inside onBeforeBrowserLaunch()
const argsPromise = onBeforeBrowserLaunch(browser, args);
const launchOptionsPromise = argsPromise
.then(function(args) {
launchOptions.args = args;
return launchOptions;
});
return launchOptionsPromise;
})
Hope this helps others as it seems that the repo owner doesn`t care.
@ViRuSTriNiTy cool solution! 👏
But thas comment at the end was really not needed.
Hi, just wanted to know if there still was a plan to merge this pr?
@ejoubaud small little ping :))
btw if you would like to, I can help with maintaining this project. I'm avid user of Cypress and have a lot of experience with it from both large and small projects. It's such a useful plugin that is helping so many people, would be a honor to help :)
another way of fixing this issue is just changing the documentation:
on('before:browser:launch', async (browser = {}, launchOptions) => {
const loader = extension.load({
source: '/path/to/xt'
alias: 'coolExtension'
});
const args = await loader(browser, []);
launchOptions.args.push(...args);
return launchOptions;
});
https://github.com/ejoubaud/cypress-browser-extension-plugin/issues/5#issuecomment-707320648