Skip to content

Commit b795e77

Browse files
gbudjeakpKrinkle
authored andcommitted
Docs: Expand QUnit.config.testFilter docs
1 parent 444a9df commit b795e77

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

docs/api/config/testFilter.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ The callback receives a `testInfo` object and must return a boolean:
3232

3333
If the callback throws an error, the error is logged as a warning and the test is skipped.
3434

35+
## Filter hierarchy
36+
37+
The `testFilter` callback runs as part of a layered filtering system:
38+
39+
1. **Test-level filters** run first: [`test.only()`](../QUnit/test.only.md), [`test.skip()`](../QUnit/test.skip.md), [`test.if()`](../QUnit/test.if.md)
40+
2. **Programmatic filter** runs next: `QUnit.config.testFilter`
41+
3. **CLI/URL filters** run last: [`--filter`](./filter.md), [`--module`](./module.md), [`--moduleId`](./moduleId.md), [`--testId`](./testId.md)
42+
43+
This layering enables:
44+
* Test authors to control test execution via `test.only()`, `test.skip()`, `test.if()`
45+
* Project maintainers to implement dynamic filtering via `testFilter`
46+
* Developers to manually filter tests via CLI or browser URL parameters
47+
3548
## Parameters
3649

3750
### `testInfo` (object)
@@ -94,3 +107,28 @@ QUnit.config.testFilter = function (testInfo) {
94107
return assignedWorker === WORKER_ID;
95108
};
96109
```
110+
111+
### Combine multiple conditions
112+
113+
```js
114+
const quarantined = ['flaky test'];
115+
116+
QUnit.config.testFilter = function (testInfo) {
117+
// Skip quarantined tests
118+
if (quarantined.some(function (p) { return testInfo.testName.indexOf(p) !== -1; })) {
119+
return false;
120+
}
121+
122+
// Skip slow tests in quick mode
123+
if (process.env.QUICK_RUN && testInfo.testName.indexOf('slow') !== -1) {
124+
return false;
125+
}
126+
127+
// Filter by module if specified
128+
if (process.env.TEST_MODULE && testInfo.module.indexOf(process.env.TEST_MODULE) === -1) {
129+
return false;
130+
}
131+
132+
return true;
133+
};
134+
```

0 commit comments

Comments
 (0)