π 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.
From 3.0.0-rc.1
onwards.
History
Version | Changes |
---|---|
v3.0.0 | only modifier to describe , it and test methods. |
v2.7.0 | 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
tip
- The
.only
modifier works exactly as its respectivedescribe
,it
andtest
methods (e.g., by runningbeforeEach
andafterEach
for thetest.only
orit.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.