Last active
August 19, 2020 21:09
-
-
Save thetutlage/6acabcc216f9e9bdf06e1c1a5d512c2d to your computer and use it in GitHub Desktop.
Jest test suite game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const actions = {} | |
describe('Broken suite', () => { | |
beforeAll(() => { | |
actions.all = {} | |
actions.all.before = true | |
}) | |
beforeEach(() => { | |
actions.each1 = {} | |
actions.each1.before = true | |
throw new Error('before each blow up') | |
}) | |
beforeEach(() => { | |
actions.each2 = {} | |
actions.each2.before = true | |
}) | |
afterEach(() => { | |
actions.each1.after = true | |
}) | |
afterEach(() => { | |
actions.each2.after = true | |
}) | |
afterAll(() => { | |
actions.all.after = true | |
console.log(actions) | |
}) | |
test('bad test', () => { | |
actions.test1 = true | |
throw new Error('test blowup') | |
}) | |
}) |
Well.. That's how I imagined it would work:
beforeAll
will run, same with first beforeEach
, but since it errors nothing will run, no tests no after hooks, whole suite is broken
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'd expect the test suite to not run since there's an exception raised in one of the
before
hook (but still expectingafter
hooks to be ran).