Skip to main content
Version: v4.x.x (Canary)

πŸ₯·πŸ» Using Plugins

History
VersionChanges
v4.0.0 (Canary)
Introduce the Plugin System.
1.2Release Candidate

Extend Poku's behavior with plugins β€” hook into the test lifecycle, customize how test files are spawned, enable inter-process communication, and more.

What Can Plugins Do?​

  • Run setup logic before the test suite begins.
  • Run teardown logic after the test suite completes.
  • Modify the command used to spawn each test file process.
  • Enable IPC channels between Poku and test processes.
  • React to each test process being spawned.
  • Customize output with custom reporters.

Quick Start​

Add plugins to your Poku configuration file via the plugins option:

// poku.config.ts
import { defineConfig } from 'poku';
import { myPlugin } from './my-plugin';

export default defineConfig({
plugins: [myPlugin],
});

Plugin Lifecycle​

Plugins are executed in the following order:

  1. setup() is called for each plugin, sequentially in array order.
  2. For each test file:
    • runner() modifies the spawn command (only the first plugin with a runner hook is used).
    • The process is spawned β€” with an IPC channel if any plugin sets ipc: true.
    • onTestProcess() is called for every plugin that defines it.
  3. After all tests complete: teardown() is called for each plugin, sequentially in array order.

Existing Plugins​

tip

Use definePlugin for type safety when creating plugins, and createReporter for custom output formatting.