Skip to main content
Version: v4.x.x

🌌 only

The .only modifier enables selective execution of tests, allowing you to focus on specific describe, it, and/or test blocks by running only those marked with .only. See the usage to understand the different conditions and behaviors.

2Stable

From 3.0.0-rc.1 onwards.

History
VersionChanges
v3.0.0
Add only modifier to describe, it and test methods.
v2.7.0
Add only modifier to describe, it and test methods (experimental).

Usage​

To enable the .only modifier, you must to pass the --only flag.

tip

You can pass the --only flag either using the test runner (Poku) or the runner you prefer, for example:

npx poku --only
npx tsx test/my-test.test.ts --only
npm test -- --only
node test/my-test.test.js --only

Common Examples​

import { describe, it, test } from 'poku';

describe.only(() => {
// βœ… Will be executed

it(() => {
// βœ… Will be executed
});

test(() => {
// βœ… Will be executed
});
});

describe(() => {
// ⏭️ Will be skipped

it(() => {
// ⏭️ Will be skipped
});

test(() => {
// ⏭️ Will be skipped
});
});

describe(() => {
// βœ… Will be executed

it(() => {
// ⏭️ Will be skipped
});

it.only(() => {
// βœ… Will be executed
});

test(() => {
// ⏭️ Will be skipped
});
});
npx poku --only

Intentional Limitations​

The .only modifier must be written directly on it, test, or describe. Aliasing it to another name or accessing it indirectly won't work because Poku doesn't track tests internally, as other test runners do. For example:

import { test } from 'poku';

const run = test.only;

run('aliased', () => {
// ❌ Won't be recognized
});

test.only('direct', () => {
// βœ… Will be recognized
});

tip
  • The .only modifier works exactly as its respective describe, it and test methods (e.g., by running beforeEach and afterEach for the test.only or it.only).
  • It's not possible to run .only modifiers without --only flag.
note

It's important to recall that Poku respects conventional JavaScript syntax in tests and doesn't change the order of the executions.