jest-circus-allure-environment
jest-circus-allure-environment copied to clipboard
Exception raised within BeforeEach will be append to all tests within same suite
In a nutshell, the main problem is that hook is not linked to test, but hook link to suite.
For BeforeAll , it's correct because beforeAll is executed one time for whole suite
but for beforeEach, it's incorrect, it should link to test, instead of suite
Example code:
describe('my suite', () => {
let i = 0
beforeEach(() => {
if(i == 1) {
i++;
throw new Error('before each exception')
}
i++;
})
it('my test', () => {
expect(1+1).toBe(3)
})
it('my test2', () => {
expect(1+1).toBe(2)
})
it('my test3', () => {
expect(1+1).toBe(2)
})
})