I want to run a function/task whenever any jest test fails. Instead of wrapping all of my test's with try/catch or add an if check, is there a way I can utilize the afterEach?
If the test fails then I want it to fail, just run a separate function.
For example:
test('nav loads correctly', async () => {
const listItems = await page.$$('[data-testid="navBarLi"]')
expect(listItems.length).toBe(4)
if (listItems.length !== 4)
await page.screenshot({path: 'screenshot.png'})
})
This is adding an if check... But I want something more robust for all of my tests.
Aucun commentaire:
Enregistrer un commentaire