You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8ab84cd
Browse filesBrowse the repository at this point in the historyBrowse files
blockResources aborts requests of the listed resource types (image,
media, font, stylesheet) before they reach the network. Unknown types
fail on helper construction.
- Playwright: context route with resourceType, registered with a
predicate so stopMockingRoute cannot remove it
- Puppeteer: cooperative request interception on every page; mockRoute,
stopMockingRoute and traffic recording continue requests
cooperatively so the blocker and mocks work together. stopMockingRoute
no longer throws on RegExp urls
- CDPBrowser: Fetch.enable with resourceType patterns and
Fetch.failRequest BlockedByClient
- WebDriver: BiDi network intercept matching the request destination
- Appium: no-op
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/configuration.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -126,6 +126,28 @@ webServer: [
126
126
127
127
The server is started as part of bootstrap, right before the `bootstrap` hook (or `bootstrapAll` for `run-workers` and `run-multiple`), and stopped after `teardown` (`teardownAll`). It starts once in the main process; workers and child processes reuse it. The interactive `shell` starts it too, `dry-run` and `check` only with `--bootstrap`. CodeceptJS stops the command and every process it spawned, including when the run is interrupted with Ctrl+C.
128
128
129
+
## Blocking Resources
130
+
131
+
Web helpers can skip loading resources a test doesn't check. Set `blockResources` in the helper config:
132
+
133
+
```js
134
+
helpers: {
135
+
Playwright: {
136
+
url:'http://localhost:3000',
137
+
blockResources: ['image', 'font', 'media'],
138
+
},
139
+
}
140
+
```
141
+
142
+
Allowed values are `image`, `media`, `font` and `stylesheet`. Any other value fails on startup. Matching requests are aborted before they reach the network, so tests no longer exercise those resources.
143
+
144
+
| Helper | How it blocks | Notes |
145
+
| --- | --- | --- |
146
+
| Playwright | context route on every page, tab and session | Routing disables Playwright's HTTP cache. A `mockRoute` for a blocked URL still serves the mock. |
147
+
| Puppeteer | request interception on every page | Request interception disables Puppeteer's page cache. A `mockRoute` for a blocked URL still serves the mock. |
148
+
| CDPBrowser | CDP `Fetch` domain | Works in Chrome. Lightpanda doesn't load images in the first place. Obscura doesn't block: it ignores `Fetch.failRequest`. |
149
+
| WebDriver | WebDriver BiDi network interception, matching the request destination | Needs BiDi, which is on by default. Every request makes a round trip to the test process. Ignored when BiDi is off. Appium ignores the option. |
150
+
129
151
## Dynamic configuration
130
152
131
153
A JS/TS config file is plain code, so you can read environment variables and build the config at runtime:
Copy file name to clipboardExpand all lines: docs/helpers/Kitesurf.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,6 +85,7 @@ Type: [object][4]
85
85
*`pollInterval`**[number][8]?** interval between checks while waiting, in milliseconds.
86
86
*`getPageTimeout`**[number][8]?** maximum time to wait for a page to load, in seconds.
87
87
*`waitForNavigation`**[string][3]?** when a navigation is considered finished: `load`, `domcontentloaded`, or `networkidle`.
88
+
*`blockResources`**[Array][15]<[string][3]>?** resource types to skip loading: `'image'`, `'media'`, `'font'`, `'stylesheet'`. Matching requests are aborted before they reach the network.
Copy file name to clipboardExpand all lines: docs/helpers/Lightpanda.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -102,6 +102,7 @@ Type: [object][4]
102
102
*`pollInterval`**[number][8]?** interval between checks while waiting, in milliseconds.
103
103
*`getPageTimeout`**[number][8]?** maximum time to wait for a page to load, in seconds.
104
104
*`waitForNavigation`**[string][3]?** when a navigation is considered finished: `load`, `domcontentloaded`, or `networkidle`.
105
+
*`blockResources`**[Array][15]<[string][3]>?** resource types to skip loading: `'image'`, `'media'`, `'font'`, `'stylesheet'`. Matching requests are aborted before they reach the network.
Copy file name to clipboardExpand all lines: docs/helpers/Moli.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,6 +91,7 @@ Type: [object][4]
91
91
*`pollInterval`**[number][8]?** interval between checks while waiting, in milliseconds.
92
92
*`getPageTimeout`**[number][8]?** maximum time to wait for a page to load, in seconds.
93
93
*`waitForNavigation`**[string][3]?** when a navigation is considered finished: `load`, `domcontentloaded`, or `networkidle`.
94
+
*`blockResources`**[Array][15]<[string][3]>?** resource types to skip loading: `'image'`, `'media'`, `'font'`, `'stylesheet'`. Matching requests are aborted before they reach the network.
Copy file name to clipboardExpand all lines: docs/helpers/Obscura.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,6 +118,7 @@ Type: [object][4]
118
118
*`pollInterval`**[number][8]?** interval between checks while waiting, in milliseconds.
119
119
*`getPageTimeout`**[number][8]?** maximum time to wait for a page to load, in seconds.
120
120
*`waitForNavigation`**[string][3]?** when a navigation is considered finished: `load`, `domcontentloaded`, or `networkidle`.
121
+
*`blockResources`**[Array][15]<[string][3]>?** resource types to skip loading: `'image'`, `'media'`, `'font'`, `'stylesheet'`. Matching requests are aborted before they reach the network.
Copy file name to clipboardExpand all lines: docs/helpers/Playwright.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,6 +79,7 @@ Type: [object][8]
79
79
*`bypassCSP`**[boolean][26]?** bypass Content Security Policy or CSP
80
80
*`highlightElement`**[boolean][26]?** highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
81
81
*`visibleLocator`**[boolean][26]?** append [`visible()`][49] to locators, so only visible elements are matched. Requires Playwright 1.63 or newer. Switch it off for a single step with `stepOpts({ visibleLocator: false })`. Not applied to `dragAndDrop`, which passes selectors to Playwright directly, nor to steps that must reach hidden elements: `grab*` methods, `scrollTo`, `seeElementInDOM`, `dontSeeElementInDOM` and `seeNumberOfElements`. When enabled, a locator matching only hidden elements fails as "element not found" instead of timing out on actionability, `strict` mode ignores hidden duplicates, and elements hidden by CSS (like a custom checkbox built on a visually hidden `input`) are no longer found.
82
+
*`blockResources`**[Array][9]<[string][7]>?** resource types to skip loading: `'image'`, `'media'`, `'font'`, `'stylesheet'`. Matching requests are aborted before they reach the network.
82
83
*`recordHar`**[object][8]?** record HAR and will be saved to `output/har`. See more of [HAR options][3].
83
84
*`testIdAttribute`**[string][7]?** locate elements based on the testIdAttribute. See more of [locate by test id][50].
84
85
*`storageState`**([string][7] | [object][8])?** Playwright storage state (path to JSON file or object)
Copy file name to clipboardExpand all lines: docs/helpers/Puppeteer.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,6 +59,7 @@ Type: [object][6]
59
59
*`browser`**[string][5]?** can be changed to `firefox` when using [puppeteer-firefox][2].
60
60
*`chrome`**[object][6]?** pass additional [Puppeteer run options][31].
61
61
*`highlightElement`**[boolean][25]?** highlight the interacting elements. Default: false. Note: only activate under verbose mode (--verbose).
62
+
*`blockResources`**[Array][18]<[string][5]>?** resource types to skip loading: `'image'`, `'media'`, `'font'`, `'stylesheet'`. Matching requests are aborted before they reach the network.
Copy file name to clipboardExpand all lines: docs/helpers/WebDriver.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,7 @@ Type: [object][19]
32
32
*`url`**[string][18]** base url of website to be tested.
33
33
*`browser`**[string][18]** Browser in which to perform testing.
34
34
*`bidiProtocol`**[boolean][34]?** WebDriver Bidi Protocol. Default: false. More info: [https://webdriver.io/docs/api/webdriverBidi/][38]
35
+
*`blockResources`**[Array][30]<[string][18]>?** resource types to skip loading: `'image'`, `'media'`, `'font'`, `'stylesheet'`. Matching requests are aborted before they reach the network.
35
36
*`basicAuth`**[string][18]?** (optional) the basic authentication to pass to base url. Example: {username: 'username', password: 'password'}
36
37
*`host`**[string][18]?** WebDriver host to connect.
37
38
*`port`**[number][23]?** WebDriver port to connect.
* @prop {number} [pollInterval=25] - interval between checks while waiting, in milliseconds.
46
46
* @prop {number} [getPageTimeout=30] - maximum time to wait for a page to load, in seconds.
47
47
* @prop {string} [waitForNavigation=load] - when a navigation is considered finished: `load`, `domcontentloaded`, or `networkidle`.
48
+
* @prop {string[]} [blockResources] - resource types to skip loading: `'image'`, `'media'`, `'font'`, `'stylesheet'`. Matching requests are aborted before they reach the network.
48
49
*/
49
50
constconfig={}
50
51
@@ -127,8 +128,10 @@ class CDPBrowser extends Helper {
0 commit comments