lundi 15 juin 2020

Cypress - update modules every describe

I have a site with i18next and I want to test if every language is loading correctly, I was able to change the browser language in the plugins/index.js file:

on('before:browser:launch', (browser, launchOptions) => {
    if (browser.family === 'chromium' && browser.name !== 'electron') {
      launchOptions.preferences.default.intl = {
        accept_languages: 'en'
      }

      return launchOptions
    }
  })
}

The problem is that I wasn't able to change this setting after the test started, I thought about using an environment variable and changing it before each describe, but it didn't work. Anyone has an idea of how I can update this plugin and relaunch the browser before each .spec file or describe?

Aucun commentaire:

Enregistrer un commentaire