🌌 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.
dica
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
dica
- The
.onlymodifier works exactly as its respectivedescribe,itandtestmethods (e.g., by runningbeforeEachandafterEachfor thetest.onlyorit.only). - It's not possible to run
.onlymodifiers without--onlyflag.
observação
It's important to recall that Poku respects conventional JavaScript syntax in tests and doesn't change the order of the executions.