Skip to content

Instantly share code, notes, and snippets.

@thetutlage
Last active August 19, 2020 21:09
Show Gist options
  • Save thetutlage/6acabcc216f9e9bdf06e1c1a5d512c2d to your computer and use it in GitHub Desktop.
Save thetutlage/6acabcc216f9e9bdf06e1c1a5d512c2d to your computer and use it in GitHub Desktop.
Jest test suite game
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')
})
})
@RomainLanz
Copy link

RomainLanz commented Aug 19, 2020

I'd expect the test suite to not run since there's an exception raised in one of the before hook (but still expecting after hooks to be ran).

@McSneaky
Copy link

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