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

Pass options to specific tests/suites in order to overwrite configuration throughout test/suite #7167

Closed
jennifer-shehane opened this issue Apr 29, 2020 · 2 comments · Fixed by #5346
Labels
type: feature New feature that does not currently exist

Comments

@jennifer-shehane
Copy link
Member

Current behavior:

Currently you can change the configuration within tests mainly be setting Cypress.config(). This will change the configuration for the duration of the entirety of tests. Sometimes you just want configuration set for the current block of test/suite.

Furthermore, in order to filter certain tests/suites by the browser we're running in, we have to use Cypress.isBrowser() to do kinda of strange filters like below:

const runOn = (browser, fn) => {
  if (Cypress.isBrowser(browser)) {
    fn()
  }
}

const ignoreOn = (browser, fn) => {
  if (!Cypress.isBrowser(browser)) {
    fn()
  }
}

// Run happy path tests if Cypress is run via Firefox
runOn('firefox', () => {
  describe('happy path suite', () => {
    it('...')
    it('...')
    it('...')
  })
})

Desired behavior:

  • users can add test configuration in object during test/suite declaration:
it('can test with config', {
    defaultCommandTimeout: 200
  }, () => {
    // test body
  })
  • run test only in certain browsers:
it('only runs in ff', {
    browser: 'firefox'
  }, () => {
  })
  • api for excluding browsers:
it('does not run in ff', {
    browser: '!firefox'
  }, () => {})
  • can apply same options for the whole suite:
describe('suite with config', {
    defaultCommandTimeout: 40
  }, () => {
	// all tests declared here will inherit the config
  })

Versions

4.5.0

@jennifer-shehane jennifer-shehane added the type: feature New feature that does not currently exist label Apr 29, 2020
@cypress-bot cypress-bot bot added the stage: needs review The PR code is done & tested, needs review label Apr 29, 2020
@kuceb kuceb mentioned this issue Apr 29, 2020
15 tasks
@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels Jun 4, 2020
@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 4, 2020

The code for this is done in cypress-io/cypress#5346, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot
Copy link
Contributor

cypress-bot bot commented Jun 8, 2020

Released in 4.8.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v4.8.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators Jun 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: feature New feature that does not currently exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant