A test framework extension to support resources teardown and cleanup in flat tests.
Writing flat (shallow) test suites has a number of advantages. However, testing frameworks rarely support
after hooks as a part of an individual test. Such support would allow to create and clean up resources necessary for a single test suite, without having to rely on
afterEach global hooks.
$ npm install test-flat --save-dev
Here's an example of a flat test suite that tears down a Puppeteer browser and cleans up afterwards as a part of a single test suite:
A test suite title.
A test suite itself.
Test suite function in
test-flatis always an asynchronous function and does not support the
An optional teardown hook to create any resources necessary for the respective test. Anything returned from this hook will be available as the
context argument in the
An optional cleanup hook executed after the test is finished (passed or failed). Accepts an optional
context argument to clean up the resources created as a part of the