Closed
Description
Version
20.5.1
Platform
mac arm64
Subsystem
test_runner
What steps will reproduce the bug?
import { it, before, describe, after } from 'node:test'
import { expect } from 'expect'
import { mainDataSource } from './config/sql/index.js'
describe('failing test suite', () => {
before(async () => {
await mainDataSource.initialize()
throw new Error('error')
})
after(async () => {
await mainDataSource.destroy()
})
it('should be ok', async () => {
expect(1).toBe(1)
})
})
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
Running the after inside the describe.
What do you see instead?
The after is not executed and the test will never finish because it's not able to close all open handles.
Additional information
Using the global before & after just works as intended
import { it, before, describe, after } from 'node:test'
import { expect } from 'expect'
import { mainDataSource } from './config/sql/index.js'
before(async () => {
await mainDataSource.initialize()
throw new Error('error')
})
after(async () => {
await mainDataSource.destroy()
})
describe('failing test suite', () => {
it('should be ok', async () => {
expect(1).toBe(1)
})
})