Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add devtools open on launch config to Cypress plugins #7822

Closed
wants to merge 10 commits into from
22 changes: 0 additions & 22 deletions cypress/plugins/index.js

This file was deleted.

27 changes: 23 additions & 4 deletions test/cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,30 @@

/**
* @type {Cypress.PluginConfig}
* @param {object} on - hook into various events Cypress emits
* @param {object} config - the resolved Cypress config
* @param {object} on - hook into various events Cypress emits.
* @param {object} config - the resolved Cypress config.
*/
// eslint-disable-next-line no-unused-vars
module.exports = (on, config) => {
/* `on` is used to hook into various events Cypress emits
`config` is the resolved Cypress config */
// Workaround to show devtools in failure screenshots.
// See https://github.com/cypress-io/cypress/issues/2024#issuecomment-754571301
on('before:browser:launch', (browser = {}, launchOptions) => {
if (browser.family === 'chromium' && browser.name !== 'electron') {
// auto open devtools
launchOptions.args.push('--auto-open-devtools-for-tabs');
}

if (browser.family === 'firefox') {
// auto open devtools
launchOptions.args.push('-devtools');
}

if (browser.name === 'electron') {
// auto open devtools
launchOptions.preferences.devTools = true;
}

// whatever you return here becomes the launchOptions
return launchOptions;
});
};