cypress-io / circleci-orb

Install, cache and run Cypress.io tests on CircleCI with minimal configuration.
https://circleci.com/orbs/registry/orb/cypress-io/cypress
MIT License
160 stars 101 forks source link

How to enabled features for chrome using this orb #396

Closed sedghi closed 1 year ago

sedghi commented 1 year ago

My local cypress config adds an argument to launch options of the chromium since I want to set SharedArrayBuffer features that I have in my app (launchOptions.args.push('--enable-features=SharedArrayBuffer');). How can I use this circleci-orb to launch chrome using that flag in the CI?

Here is my config

export default defineConfig({
  chromeWebSecurity: false,
  e2e: {
    supportFile: 'cypress/support/index.js',
    setupNodeEvents(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

        console.log(launchOptions.args); // print all current args

        console.log('***', browser.family, browser.name, '***');
        if (browser.family === 'chromium' && browser.name !== 'electron') {
          // auto open devtools
          launchOptions.args.push('--enable-features=SharedArrayBuffer');
        }

        // whatever you return here becomes the launchOptions
        return launchOptions;
      });
    },
    baseUrl: 'http://localhost:3000',
    waitForAnimations: true,
    chromeWebSecurity: false,
    defaultCommandTimeout: 10000,
    requestTimeout: 10000,
    responseTimeout: 10000,
    specPattern: 'cypress/integration/**/*.spec.[jt]s',
    projectId: '4oe38f',
    video: false,
    reporter: 'junit',
    reporterOptions: {
      mochaFile: 'cypress/results/test-output.xml',
      toConsole: true,
    },
  },
});
jennifer-shehane commented 1 year ago

It's not possible to pass the arguments directly to Chrome from the orb.

If you want a different config. with different launch options for chromium, during local versus CI, you could pass a different configFile as a CLI flag to the cypress-command command - this is possible in the new 3.0.0 version of our orb. which accepts any CLI flags that you could normally pass through the terminal.