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

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

@Ashish-chamoli002

Description

@Ashish-chamoli002

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions