codeceptjs 4.1.0 → 4.2.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/alternative-browsers.md +153 -0
- package/docs/basics.md +9 -1
- package/docs/configuration.md +2 -0
- package/docs/helpers/CDPBrowser.md +2138 -0
- package/docs/helpers/Kitesurf.md +118 -0
- package/docs/helpers/Obscura.md +210 -0
- package/docs/migration-4.md +3 -1
- package/docs/parallel.md +10 -0
- package/docs/plugins/screencast.md +18 -13
- package/docs/plugins.md +1 -1
- package/lib/command/info.js +11 -3
- package/lib/command/workers/runTests.js +14 -20
- package/lib/container.js +6 -0
- package/lib/data/context.js +4 -0
- package/lib/element/WebElement.js +5 -0
- package/lib/helper/Appium.js +14 -2
- package/lib/helper/CDPBrowser.js +3004 -0
- package/lib/helper/Kitesurf.js +139 -0
- package/lib/helper/Obscura.js +344 -0
- package/lib/helper/Playwright.js +30 -3
- package/lib/helper/Puppeteer.js +43 -16
- package/lib/helper/WebDriver.js +43 -8
- package/lib/helper/clientscripts/cdpBrowserClient.js +486 -0
- package/lib/helper/clientscripts/xpathPolyfill.js +31 -0
- package/lib/helper/extras/CDPConnection.js +92 -0
- package/lib/helper/extras/CDPElementHandle.js +27 -0
- package/lib/helper/extras/apngAssembler.js +156 -0
- package/lib/html.js +9 -2
- package/lib/listener/retryEnhancer.js +2 -1
- package/lib/listener/steps.js +8 -0
- package/lib/mocha/hooks.js +10 -0
- package/lib/parser.js +14 -2
- package/lib/plugin/junitReporter.js +17 -1
- package/lib/plugin/screencast.js +116 -24
- package/lib/step/base.js +15 -3
- package/lib/utils/loaderCheck.js +6 -0
- package/lib/utils.js +1 -1
- package/lib/workers.js +17 -0
- package/package.json +4 -1
- package/typings/promiseBasedTypes.d.ts +1833 -0
- package/typings/types.d.ts +1840 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
---
|
|
2
|
+
permalink: /alternative-browsers
|
|
3
|
+
title: Alternative Browser Engines
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Alternative Browser Engines
|
|
7
|
+
|
|
8
|
+
Playwright and Puppeteer drive full Chromium — the most accurate way to test what users see.
|
|
9
|
+
But a new class of lightweight, agent-era browsers has appeared, and CodeceptJS can drive them
|
|
10
|
+
through the `CDPBrowser` helper family:
|
|
11
|
+
|
|
12
|
+
- **[Obscura](https://github.com/h4ckf0r0day/obscura)** — an open-source Rust browser with a real
|
|
13
|
+
V8 engine. From v0.2.0, the default release build also renders — real layout, computed styles,
|
|
14
|
+
and screenshots — with `-no-render` builds still available for pure-speed, nothing-painted
|
|
15
|
+
scraping mode. A single 70 MB binary, ~30 MB RAM per instance, page loads in tens of
|
|
16
|
+
milliseconds.
|
|
17
|
+
- **[Kitesurf](https://blog.cloudflare.com/kitesurf/)** — Cloudflare's browser that runs in V8
|
|
18
|
+
isolates on Cloudflare Workers, with a real layout and rendering pipeline. Cloud-only,
|
|
19
|
+
free in beta, planned to be open-sourced.
|
|
20
|
+
|
|
21
|
+
Both speak Chrome DevTools Protocol. CodeceptJS drives them with raw CDP — one round-trip per
|
|
22
|
+
action, no stale element handles — which is why suites on these browsers run fast and never hang
|
|
23
|
+
on navigation races.
|
|
24
|
+
|
|
25
|
+
## When are they better than Playwright?
|
|
26
|
+
|
|
27
|
+
**Smoke suites where seconds matter.** An Obscura scenario (navigate, fill a form, submit,
|
|
28
|
+
assert) completes in 150–500 ms. There is no browser binary to download in CI — a 70 MB
|
|
29
|
+
static binary starts instantly. If your PR gate runs 50 smoke scenarios, Obscura turns
|
|
30
|
+
minutes into seconds.
|
|
31
|
+
|
|
32
|
+
**Massive parallel scale.** Kitesurf sessions are Cloudflare Workers — they spawn in about a
|
|
33
|
+
second, cost nothing while idle, and there is no practical ceiling on how many you run at once.
|
|
34
|
+
Combined with `run-workers`, every worker acquires its own cloud browser:
|
|
35
|
+
|
|
36
|
+
// codecept.conf.js — each worker independently loads the config,
|
|
37
|
+
// so each one gets its own Kitesurf session automatically
|
|
38
|
+
export const config = {
|
|
39
|
+
helpers: {
|
|
40
|
+
Kitesurf: {
|
|
41
|
+
url: 'https://staging.myapp.com',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
npx codeceptjs run-workers 16
|
|
47
|
+
|
|
48
|
+
Sixteen cloud browsers, zero local resources, feedback in the time of your slowest test.
|
|
49
|
+
Scale the number up as far as your suite can split — the browsers are no longer
|
|
50
|
+
the bottleneck, and your CI runner only coordinates.
|
|
51
|
+
|
|
52
|
+
**Testing the DOM, not the pixels.** Most functional assertions — text appears, form submits,
|
|
53
|
+
redirect happens, cookie is set — do not need a GPU raster pipeline. Obscura executes your
|
|
54
|
+
app's real JavaScript in real V8; it only skips painting. For API-adjacent flows
|
|
55
|
+
(login → dashboard data appears), that is exactly the right amount of browser.
|
|
56
|
+
|
|
57
|
+
**Constrained environments.** ARM CI runners, thin containers, air-gapped machines:
|
|
58
|
+
a static binary with no system dependencies goes where Chromium will not.
|
|
59
|
+
|
|
60
|
+
**Scraping-grade network realism.** Obscura's stealth mode presents a consistent Chrome TLS
|
|
61
|
+
fingerprint — useful when your tests must pass through bot-protection layers that block
|
|
62
|
+
headless Chromium.
|
|
63
|
+
|
|
64
|
+
## When to stay with Playwright
|
|
65
|
+
|
|
66
|
+
- Anything visual: visual regression, PDF (neither helper exposes PDF output). Obscura's v0.2.0+
|
|
67
|
+
rendering/CSS engine is new and independently implemented — expect edge cases and gaps versus a
|
|
68
|
+
real browser, especially around inherited properties and less common computed-style values.
|
|
69
|
+
- Visibility semantics on `-no-render` Obscura builds (and v0.1.x): every element reports as
|
|
70
|
+
visible — `seeElement`/`dontSeeElement` throw and point you to `seeElementInDOM`. On v0.2.0+
|
|
71
|
+
default builds, `CDPBrowser` detects the real layout engine per binary and visibility works
|
|
72
|
+
normally.
|
|
73
|
+
- Complex input: drag-and-drop, hover chains, file uploads, iframes, multi-tab, service workers.
|
|
74
|
+
- Cross-browser coverage (Firefox, WebKit).
|
|
75
|
+
- Testing local apps with Kitesurf: the cloud browser must reach your app; use a tunnel
|
|
76
|
+
(`cloudflared tunnel --url http://localhost:3000`) or a deployed environment.
|
|
77
|
+
|
|
78
|
+
## Configuration
|
|
79
|
+
|
|
80
|
+
helpers: {
|
|
81
|
+
Obscura: {
|
|
82
|
+
url: 'http://localhost:3000',
|
|
83
|
+
},
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
helpers: {
|
|
87
|
+
Kitesurf: {
|
|
88
|
+
url: 'https://staging.myapp.com',
|
|
89
|
+
accountId: process.env.CF_ACCOUNT_ID,
|
|
90
|
+
apiToken: process.env.CF_API_TOKEN,
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
Any other CDP endpoint works through the base helper:
|
|
95
|
+
|
|
96
|
+
helpers: {
|
|
97
|
+
CDPBrowser: {
|
|
98
|
+
url: 'http://localhost:3000',
|
|
99
|
+
endpoint: 'http://127.0.0.1:9222',
|
|
100
|
+
},
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
### Obscura's three connection modes
|
|
104
|
+
|
|
105
|
+
Obscura manages its own `obscura serve` process, the same way Playwright manages its own browser
|
|
106
|
+
process — there is nothing to start by hand in the common case:
|
|
107
|
+
|
|
108
|
+
- **Self-launch (default)** — leave `endpoint` unset. The helper resolves a binary
|
|
109
|
+
(`binaryPath` in the config, then `OBSCURA_PATH`, then `obscura` on `PATH`), spawns
|
|
110
|
+
`obscura serve` on a free port, and kills it when the run ends. Not setting `port` is
|
|
111
|
+
intentional: a free port is picked automatically, which is what makes `run-workers`
|
|
112
|
+
collision-free — every worker gets its own instance without any config.
|
|
113
|
+
|
|
114
|
+
helpers: {
|
|
115
|
+
Obscura: {
|
|
116
|
+
url: 'http://localhost:3000',
|
|
117
|
+
binaryPath: '/usr/local/bin/obscura', // optional override, like Playwright's executablePath
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
- **Attach** — set `endpoint` explicitly to connect to an Obscura instance you manage yourself
|
|
122
|
+
(already running locally, in a container, or on a remote host). The helper only connects; it
|
|
123
|
+
never spawns or kills anything.
|
|
124
|
+
|
|
125
|
+
helpers: {
|
|
126
|
+
Obscura: {
|
|
127
|
+
url: 'http://localhost:3000',
|
|
128
|
+
endpoint: 'http://127.0.0.1:9222',
|
|
129
|
+
},
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
- **Courtesy-attach** — only relevant when `endpoint` is unset and no binary can be resolved
|
|
133
|
+
either. If something is already answering on the conventional `http://127.0.0.1:9222`, the
|
|
134
|
+
helper attaches to it (and, again, never kills it) instead of failing outright. This exists so
|
|
135
|
+
that "start Obscura by hand and just run the tests" keeps working without any config, while
|
|
136
|
+
self-launch is still the default for everyone else.
|
|
137
|
+
|
|
138
|
+
## Capability matrix
|
|
139
|
+
|
|
140
|
+
| | Playwright | Obscura | Kitesurf |
|
|
141
|
+
|---|---|---|---|
|
|
142
|
+
| Real JS execution (V8) | yes | yes | yes |
|
|
143
|
+
| Layout / getBoundingClientRect | yes | yes (v0.2.0+ default builds); synthetic on `-no-render`/v0.1.x | yes |
|
|
144
|
+
| Screenshots | yes | yes (v0.2.0+ default builds); no on `-no-render`/v0.1.x | yes |
|
|
145
|
+
| Visibility assertions | yes | yes (v0.2.0+ default builds); no, DOM-presence only, on `-no-render`/v0.1.x | yes |
|
|
146
|
+
| Screencast / video (`screencast` plugin) | yes — WebM via `page.screencast`, with caption burn-in | yes — APNG via CDP `Page.startScreencast`, assembled in-process (v0.2.0+ default builds; verified PNG frames on the live server); no caption burn-in | untested |
|
|
147
|
+
| Startup cost | seconds + ~300 MB install | instant, 70 MB binary | ~1 s, zero local |
|
|
148
|
+
| Parallel scale | machine-bound | machine-bound (light) | near-unlimited (cloud) |
|
|
149
|
+
| Where it runs | local/grid | local | Cloudflare only |
|
|
150
|
+
| License / cost | open source | Apache-2.0 | proprietary, free beta |
|
|
151
|
+
|
|
152
|
+
See helper reference pages: [CDPBrowser](/helpers/CDPBrowser), [Obscura](/helpers/Obscura),
|
|
153
|
+
[Kitesurf](/helpers/Kitesurf).
|
package/docs/basics.md
CHANGED
|
@@ -239,7 +239,15 @@ I.uncheckOption('Subscribe')
|
|
|
239
239
|
> Use `secret()` for sensitive data: `I.fillField('password', secret('123456'))` - [won't expose in logs](/secrets/).
|
|
240
240
|
>
|
|
241
241
|
|
|
242
|
-
> [selectOption](/web-api#iselectoption) works with native `<select>` elements as well as custom components using `role="combobox"` or `role="
|
|
242
|
+
> [selectOption](/web-api#iselectoption) works with native `<select>` elements as well as custom components using `role="combobox"`, `role="listbox"`, or `role="radiogroup"`.
|
|
243
|
+
>
|
|
244
|
+
> For a radio group the option is matched against the accessible name of a `role="radio"` item, so a group of buttons reads the same way as a `<select>`:
|
|
245
|
+
>
|
|
246
|
+
> ```js
|
|
247
|
+
> I.selectOption('Density', 'Comfortable')
|
|
248
|
+
> ```
|
|
249
|
+
>
|
|
250
|
+
> A radio group holds a single value, so passing an array of options raises an error.
|
|
243
251
|
|
|
244
252
|
### Assertions
|
|
245
253
|
|
package/docs/configuration.md
CHANGED
|
@@ -44,6 +44,8 @@ export const config = {
|
|
|
44
44
|
|
|
45
45
|
- `timeout` — default per-test timeout in seconds; a test is killed if it stops responding.
|
|
46
46
|
- `mocha` — [Mocha options](https://mochajs.org/#configuring-mocha-nodejs), including extra reporters. See [Reporters](/reports).
|
|
47
|
+
- `workerInitializationDelay` — delay in milliseconds between spinning up parallel workers to prevent CPU spikes and stagger browser startup. Defaults to `200`. Set to `0` to disable.
|
|
48
|
+
- `workerInitializationMaxDelay` — maximum total delay (in milliseconds) for worker initialization staggering. Defaults to `10000` (10 s). Set to `0` to disable capping.
|
|
47
49
|
|
|
48
50
|
**BDD**
|
|
49
51
|
|