Per File
Running a callback before and after each test fileβ
-
poku
API -
poku
CLI
Poku brings a simple way to perform a callback before and/or after every test file.
- test/run.test.js
import { poku } from 'poku';
const prepareService = () => new Promise((resolve) => resolve(undefined));
const resetService = () => new Promise((_, reject) => reject('Let\'s crash it'));
await poku('test/unit', {
beforeEach: prepareService,
afterEach: resetService,
});
npx poku test/run.test.js
Success Case
Failure Case (check the debug)
tip
The "per-file" mode comes close to plugins, even though that wasn't the original intention.
danger
Although it also works with parallel
runs, it's strongly discouraged to use these features for concurrent tests.