Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions test/hooks.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { it, describe, assert, beforeAll, afterAll, beforeEach, afterEach } from '../src'

describe('before and after hooks', () => {
let eachState = 'start'
let eachCount = 0
let allState = 'start'
let allCount = 0

beforeAll(() => {
allState = 'running'
})
afterAll(() => {
allState = 'done'
allCount++
})

beforeEach(() => {
eachState = 'running'
})
afterEach(() => {
eachState = 'done'
eachCount++
})

it('beforeEach works', () => {
assert.equal(eachState, 'running')
})

// It should work if tests are run in serial, skip for now
it.skip('afterEach called', () => {
assert.equal(eachState, 'running')
assert.equal(eachCount, 1)
})

it('beforeAll works', () => {
assert.equal(allState, 'running')
})

it('afterAll not called', () => {
assert.equal(allState, 'running')
assert.equal(allCount, 0)
})
})