Skip BDD Scenario at runtime using custom hook #3349
              
                Unanswered
              
          
                  
                    
                      brunoklein
                    
                  
                
                  asked this question in
                Q&A
              
            Replies: 0 comments
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
        
    
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello CodeceptJS community!
Is there any proper way to skip a BDD scenario at runtime?
As I didn't find a proper solution for this on CodeceptJS docs I decided to create my own solution :) I would like to see your thoughts and also appreciate any feedback.
Feature file:
Steps file:
Custom hook file:
How it works
The test step validates the element (or anything you want) inside a tryTo;
If the element is not available then we throw an error with a custom message containing 'Skip Test';
On custom hook level, for failed event, we catch the message and use the test.skip() function;
*Note the test.skip() function is inside a try/catch because it throws an error:nding { message: 'async skip; aborting execution' }.
The final result on Allure looks like this:
Beta Was this translation helpful? Give feedback.
All reactions