cypress-io / cypress-grep

Filter tests using substring
137 stars 19 forks source link

`before` and `after` hooks always get called even spec (`describe` or `it`) doesn't have targeted tags #90

Closed hiendnguyen closed 2 years ago

hiendnguyen commented 2 years ago

Below is sample spec

// test.ts
describe('Template', { tags: '@p100' }, () => {
  before(() => {
    console.log('before all book')
  })

  beforeEach(() => {
    console.log('beforeEach hook')
  })

  afterEach(() => {
    console.log('afterEach hook')
  })

  after(() => {
    console.log('after all hook')
  })

  it('test case 01', () => {
    console.log('ahh, test case')
  })
})

Open runner by calling npx cypress open --env grepTags=@smoke and run test.ts spec by clicking on it on runner

Observe that before and after hooks get called image

thetif commented 2 years ago

I am also have this issue.

wqsandoval commented 2 years ago

I have the same issue , all before hooks are called making our build pipeline take much longer than needed

rgschulte commented 2 years ago

I am having the same issue. Before's are called making building waaaaaaay longer than expected

hiendnguyen commented 2 years ago

The below combination is working for me