Skip to main content
Version: v4.x.x

Per File

Running a callback before and after each test file​

  • poku.config.js
  • .pokurc.jsonc
  • poku CLI

Poku brings a simple way to perform a callback before and/or after every test file.

import { defineConfig } from 'poku';

const prepareService = () => new Promise((resolve) => resolve(undefined));
const resetService = () => new Promise((_, reject) => reject('Let\'s crash it'));

export default defineConfig({
include: 'test/unit',
beforeEach: prepareService,
afterEach: resetService,
});
npx poku
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, prefer to use --sequential instead.