Skip to content
Discussion options

You must be logged in to vote

I created a solution - in wdio.conf file I added a countItBlocksInFile that will count how many it blocks we have in a spec file

const countItBlocksInFile = (filePath) => {
    const content = fs.readFileSync(filePath, 'utf-8');
    const matches = content.match(/it\(\s*['"`](.*?)['"`]\s*,/g);
    return matches ? matches.length : 0;
}

Then I use it in beforeSuite hook. At the same time, I added a counter++ in beforeTest hook. So in order to not call reloadSession after the last test:

afterTest: async function() {
    if(runCounter < numberOfTests){
        await browser.reloadSession()
    }
}

Reports are working fine in BrowserStack

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
2 replies
@jadersonts
Comment options

@christian-bromann
Comment options

Comment options

You must be logged in to vote
1 reply
@DhanalakshmiRamasamy
Comment options

Answer selected by christian-bromann
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants