Skip to content
This repository has been archived by the owner on Mar 29, 2023. It is now read-only.

Runs before block as well although the tests don't run #28

Closed
vkolgi opened this issue May 7, 2021 · 7 comments
Closed

Runs before block as well although the tests don't run #28

vkolgi opened this issue May 7, 2021 · 7 comments

Comments

@vkolgi
Copy link

vkolgi commented May 7, 2021

One specific issue is that the before block runs for tests which are not supposed to run.

describe('My First Test', () => {

  it('Does not do much! @smoke', () => {
    expect(true).to.equal(true)
  })

  it("Does not do much either!, but shouldn't run", () => {
    expect(true).to.equal(true)
  })

})

describe('Tests with before block', () => {

  before('You know, setting up fixtures', () => {
    cy.visit('http://google.com')
    cy.log('setting up fixtures')
  })

  it('Tests with the before block', () => {
    expect(true).to.equal(true)
  })

  it("Tests with the before block, again", () => {
    expect(true).to.equal(true)
  })

})

Strangely the commands of the before block doesn't show up in the command log.
Here if I grep with @smoke the tests in second describe block won't run but the before block does. Is there any way to skip them as well ?

@bahmutov
Copy link
Collaborator

bahmutov commented May 7, 2021 via email

@vkolgi
Copy link
Author

vkolgi commented May 7, 2021

Not sure if there is a workaround for this, I want to take a stab at this.
From the code it looks like it's harder to get some sort of look ahead, where skip before block if corresponding tests are not supposed to run.

@vkolgi
Copy link
Author

vkolgi commented May 7, 2021

@bahmutov I tried with the it.skip for all the tests in second block. It still runs the before hook.
Hmm, It would be costly to run before blocks of all the tests when we run subset of test suite (e.g. smoke), especially when these fixtures are used to fire APIs to setup the tests.

@bahmutov
Copy link
Collaborator

bahmutov commented May 7, 2021 via email

@vkolgi
Copy link
Author

vkolgi commented May 7, 2021

Yeah since this is consistent with mocha, shall I close the issue ?

@bahmutov
Copy link
Collaborator

bahmutov commented May 7, 2021 via email

@vkolgi
Copy link
Author

vkolgi commented May 7, 2021

Closing the issue, since this is consistent with mocha and plugin cannot do much.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants