bahmutov / cypress-select-tests

User space solution for picking Cypress tests to run
96 stars 14 forks source link

Before & Wrap don't work together? #115

Open RobertLowe opened 4 years ago

RobertLowe commented 4 years ago

This doesn't seem to work:

describe('Something', () => {
  before(() => {
    cy.task('fixtures:user').then(data => {
      return cy.wrap(data).as('userData')
    });
  });

  it('should get user data', () => {
    cy.get('@userData').then(userData => {
      // stuff
    })
  })
})

This does:

describe('Something', () => {
  it('should get user data', () => {
    cy.task('fixtures:user').then(data => {
      return cy.wrap(data).as('userData')
    });

    cy.get('@userData').then(userData => {
      // stuff
    })
  })
})

When using: cypress run --browser chrome --spec=./cypress/integration/example.js --env grep="should get user data"

Which is odd because if I throw inside the before, I can see that the before is actually run.

Any ideas?

It produces: CypressError: cy.get() could not find a registered alias for: '@userData'