-
-
Notifications
You must be signed in to change notification settings - Fork 274
Closed
tapjs/libtap
#50Description
I have a test that looks like the following (Pseudocode):
const db = connectToDatabase();
t.teardown(() => db.drop()); // drop-database
const connection = db.connect();
t.teardown(() => connection.close()); // close-connectionIf I run the test I get an error, because I can't drop the database with open connections.
This is because tap runs the teardown functions in the order in which there are defined:
drop-databaseclose-connection
I would expect that they are run in the reverse order:
close-connectiondrop-database
This way all connections would be closed before the database is dropped. This would also match the behavior of other test runners:
- ava (must be configured, default in the next major release) Add ability to reverse the order of teardown steps avajs/ava#2495
- jest. I didn't find good documentation explaining this but if I run:
It logs:
beforeAll(() => console.log('Before each 1')) afterAll(() => console.log('After all 1')) beforeAll(() => console.log('Before each 2')) afterAll(() => console.log('After all 2')) it('should test', () => console.log('Test'))Before each 1 Before each 2 Test After all 2 After all 1
judofyr and dwickern
Metadata
Metadata
Assignees
Labels
No labels