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

Root after hook is executed when onlyOn condition is met #167

Open
Ashish-chamoli002 opened this issue Oct 1, 2021 · 0 comments
Open

Root after hook is executed when onlyOn condition is met #167

Ashish-chamoli002 opened this issue Oct 1, 2021 · 0 comments

Comments

@Ashish-chamoli002
Copy link

Cypress: 8.4.0/8.5.0
Node: 14.0.0
Typescript: 4.3.2
We have nested describe structure for our test as shown below:

describe('someTest',()=>{
   let someVar;
   after(()=>{
      someVar=null;
   });
   before(()=> {
     loginApp(...);
   });
   describe('when feature flag is on',()=>{
       before(()=>{
           onlyOn(...);
       })
       it('should....')
       describe('the user clicks on 1...')
       describe('the user clicks on 2 ...')
   })
});

what’s happening in the above is that when onlyOn is true, for some reason cypress (or something cypress does to mocha) is looking to execute an after() block immediately after the before(). It is “finding” the one at the root and executing it so the variables are prematurely null’d. So our session ends when control go for describe('the user clicks on 1...').

P.S. after() and before() are hooks.

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

1 participant