Skip to main content
Version: v4.x.x

testNamePattern

Only run tests whose title matches the given pattern.

History
VersionChanges
v4.2.0
Introduces testNamePattern option.

Unlike filter which matches file paths, testNamePattern matches individual test titles (it and test blocks).

CLI​

# Run only tests containing "auth" in the title

npx poku --testNamePattern='auth' ./test
# Short flag

npx poku -t='auth' ./test

Config File​

{
"$schema": "https://poku.io/schemas/configs.json",
"testNamePattern": "auth"
}

API​

await poku('./test', {
testNamePattern: /auth/,
});

Example​

Given a test file:

import { test, assert } from 'poku';

test('Auth: login with valid credentials', () => {
assert(true);
});

test('Auth: reject invalid token', () => {
assert(true);
});

test('Users: list all users', () => {
assert(true);
});

Running with --testNamePattern='Auth:' will only execute the two Auth tests, skipping Users: list all users:

npx poku -t='Auth:' ./test

tip

To skip specific tests by title instead, see testSkipPattern. To filter by file path, see filter.

info

This option is inspired by Node.js' --test-name-pattern, Jest's --testNamePattern, and Vitest's --testNamePattern.