Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running tests with flags from chrome cypress

I have some test cases that use webcam and our test enviroment needs for using webcam to have set flag in chrome --unsafely-treat-insecure-origin-as-secure

How can I for some test sets have this set in chrome with cypress?

Thanks

like image 705
Lumca Avatar asked Oct 14 '25 14:10

Lumca


1 Answers

You can pass flags to the chrome browser in Cypress by writing a Cypress plugin as seen in the official documentation here: https://docs.cypress.io/api/plugins/browser-launch-api.html#Usage.

Navigate to your cypress/plugins directory and add the following code

module.exports = (on, config) => {
  on('before:browser:launch', (browser = {}, launchOptions) => {
    // `args` is an array of all the arguments that will
    // be passed to browsers when it launches
  
    if (browser.name === 'chrome') {
      launchOptions.args.push('--unsafely-treat-insecure-origin-as-secure');
    }


    // whatever you return here becomes the launchOptions
    return launchOptions;
  });
};
like image 58
Paul Jerome Avatar answered Oct 18 '25 03:10

Paul Jerome



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!