codeceptjs 4.2.1-beta.3 → 4.2.2
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/README.md +2 -0
- package/docs/alternative-browsers.md +56 -1
- package/docs/helpers/Appium.md +4 -0
- package/docs/helpers/Kitesurf.md +42 -20
- package/docs/helpers/Lightpanda.md +1836 -8
- package/docs/helpers/Moli.md +1956 -0
- package/docs/helpers/Obscura.md +43 -21
- package/docs/helpers/Playwright.md +4 -0
- package/docs/helpers/Puppeteer.md +74 -52
- package/docs/helpers/WebDriver.md +4 -0
- package/docs/installation.md +18 -0
- package/docs/lint.md +111 -0
- package/docs/mobile.md +1 -0
- package/docs/mobilewright.md +166 -0
- package/lib/command/run-multiple.js +7 -2
- package/lib/container.js +1 -1
- package/lib/helper/Decision.js +1 -1
- package/lib/helper/Moli.js +125 -0
- package/lib/helper/WebDriver.js +3 -6
- package/lib/mocha/cli.js +2 -2
- package/lib/mocha/index.js +1 -2
- package/lib/mocha/suite.js +1 -1
- package/lib/mocha/test.js +1 -2
- package/lib/mocha/ui.js +3 -3
- package/lib/plugin/pause.js +1 -1
- package/package.json +31 -34
- package/typings/promiseBasedTypes.d.ts +106 -0
- package/typings/types.d.ts +106 -0
package/README.md
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
| 🌐 Web | WebDriver | [](https://github.com/codeceptjs/CodeceptJS/actions/workflows/webdriver.yml) |
|
|
13
13
|
| 🌐 Web | Obscura | [](https://github.com/codeceptjs/CodeceptJS/actions/workflows/obscura.yml) |
|
|
14
14
|
| 🌐 Web | Lightpanda | [](https://github.com/codeceptjs/CodeceptJS/actions/workflows/lightpanda.yml) |
|
|
15
|
+
| 🌐 Web | Moli | [](https://github.com/codeceptjs/CodeceptJS/actions/workflows/moli.yml) |
|
|
15
16
|
| 📱 Mobile | Appium | [](https://github.com/codeceptjs/CodeceptJS/actions/workflows/appium_Android.yml) |
|
|
16
17
|
|
|
17
18
|
# CodeceptJS [](https://stand-with-ukraine.pp.ua)
|
|
@@ -46,6 +47,7 @@ CodeceptJS uses **Helper** modules to provide actions to `I` object. Currently,
|
|
|
46
47
|
- [**WebDriver**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/WebDriver.md) - uses [webdriverio](http://webdriver.io/) to run tests via WebDriver or Devtools protocol.
|
|
47
48
|
- [**Obscura**](https://codecept.io/helpers/Obscura) - drives the lightweight Obscura browser through Chrome DevTools Protocol. See [Alternative Browser Engines](https://codecept.io/alternative-browsers).
|
|
48
49
|
- [**Lightpanda**](https://codecept.io/helpers/Lightpanda) - drives the Lightpanda headless browser through Chrome DevTools Protocol. See [Alternative Browser Engines](https://codecept.io/alternative-browsers).
|
|
50
|
+
- [**Moli**](https://codecept.io/helpers/Moli) - drives the Moli headless browser through Chrome DevTools Protocol. See [Alternative Browser Engines](https://codecept.io/alternative-browsers).
|
|
49
51
|
- [**Appium**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Appium.md) - for **mobile testing** with Appium
|
|
50
52
|
- [**Detox**](https://github.com/codeceptjs/CodeceptJS/blob/master/docs/helpers/Detox.md) - This is a wrapper on top of Detox library, aimed to unify testing experience for CodeceptJS framework. Detox provides a grey box testing for mobile applications, playing especially well for React Native apps.
|
|
51
53
|
|
|
@@ -6,7 +6,7 @@ title: Alternative Browser Engines
|
|
|
6
6
|
# Alternative Browser Engines
|
|
7
7
|
|
|
8
8
|
::: warning Experimental
|
|
9
|
-
The `Obscura`, `Lightpanda` and `Kitesurf` helpers are experimental. Keep a Playwright or WebDriver job for compatibility-critical tests.
|
|
9
|
+
The `Obscura`, `Lightpanda`, `Moli` and `Kitesurf` helpers are experimental. Keep a Playwright or WebDriver job for compatibility-critical tests.
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
Playwright drives full Chromium, Firefox and WebKit: the most accurate way to test what users see, at the cost of a heavy browser per worker. Alternative engines trade part of that accuracy for speed, a small footprint, or cloud scale. They are a good fit for functional tests (text appears, form submits, redirect happens, cookie is set) and a poor one for anything visual.
|
|
@@ -143,6 +143,61 @@ Lightpanda: {
|
|
|
143
143
|
|
|
144
144
|
All options: [Lightpanda helper reference](/helpers/Lightpanda).
|
|
145
145
|
|
|
146
|
+
## Moli
|
|
147
|
+
|
|
148
|
+
[Moli](https://github.com/lexmount/moli) is an open-source headless browser built in Rust for automation. It runs your app's JavaScript in V8 and computes real CSS, but skips layout and painting, so it starts fast and stays small. Visibility checks such as `seeElement` and `waitForVisible` work.
|
|
149
|
+
|
|
150
|
+
Limitations:
|
|
151
|
+
|
|
152
|
+
- No screenshots: `saveScreenshot`, failure screenshots and the `screencast` plugin do not work.
|
|
153
|
+
- `clickXY` does not work.
|
|
154
|
+
- `attachFile` uploads files without a MIME type; the server receives `application/octet-stream`.
|
|
155
|
+
- Links have no default color: `a` computes `color: rgb(0, 0, 0)`.
|
|
156
|
+
|
|
157
|
+
### Setup
|
|
158
|
+
|
|
159
|
+
Install Moli following the [official instructions](https://github.com/lexmount/moli#direct-installation) and put `moli` on `PATH`. Then enable the helper:
|
|
160
|
+
|
|
161
|
+
```js
|
|
162
|
+
// codecept.conf.js
|
|
163
|
+
export const config = {
|
|
164
|
+
helpers: {
|
|
165
|
+
Moli: {
|
|
166
|
+
url: 'http://localhost:3000',
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
If the binary is not on `PATH`, set `binaryPath` in the config or the `MOLI_PATH` environment variable.
|
|
173
|
+
|
|
174
|
+
### Usage
|
|
175
|
+
|
|
176
|
+
```sh
|
|
177
|
+
npx codeceptjs run
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The helper starts `moli serve` on a free port before the first test and stops it after the last one. Each worker gets its own instance:
|
|
181
|
+
|
|
182
|
+
```sh
|
|
183
|
+
npx codeceptjs run-workers 8
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
To connect to a Moli you started yourself, set `endpoint`; the helper then never starts or stops it:
|
|
187
|
+
|
|
188
|
+
```sh
|
|
189
|
+
moli serve --host 127.0.0.1 --port 9222
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
```js
|
|
193
|
+
Moli: {
|
|
194
|
+
url: 'http://localhost:3000',
|
|
195
|
+
endpoint: 'http://127.0.0.1:9222',
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
All options: [Moli helper reference](/helpers/Moli).
|
|
200
|
+
|
|
146
201
|
## Kitesurf
|
|
147
202
|
|
|
148
203
|
[Kitesurf](https://blog.cloudflare.com/kitesurf/) is Cloudflare's browser running on Cloudflare Workers, with a real layout and rendering pipeline. Sessions start in about a second and nothing runs on your machine, so the number of parallel browsers is limited only by how far your suite splits.
|
package/docs/helpers/Appium.md
CHANGED
|
@@ -256,6 +256,10 @@ I.dontSee('#add-to-cart-btn');
|
|
|
256
256
|
|
|
257
257
|
Returns **void** automatically synchronized promise through #recorder
|
|
258
258
|
|
|
259
|
+
### capabilities
|
|
260
|
+
|
|
261
|
+
Type: CodeceptJS.HelperCapabilities
|
|
262
|
+
|
|
259
263
|
### checkIfAppIsInstalled
|
|
260
264
|
|
|
261
265
|
Returns app installation status.
|
package/docs/helpers/Kitesurf.md
CHANGED
|
@@ -79,7 +79,7 @@ Type: [object][4]
|
|
|
79
79
|
* `apiBase` **[string][3]?** Cloudflare API base URL
|
|
80
80
|
* `input` **[string][3]?** how actions are dispatched: `cdp` (real mouse and keyboard events) or `synthetic` (DOM events).
|
|
81
81
|
* `capabilities` **[object][4]?** browser capabilities; Kitesurf sets `{ layout: 'real', screenshot: true }`.
|
|
82
|
-
* `xpathPolyfill` **([string][3] | [boolean][
|
|
82
|
+
* `xpathPolyfill` **([string][3] | [boolean][18])?** inject an XPath polyfill for browsers with incomplete XPath support. `auto` detects when it is needed.
|
|
83
83
|
* `waitForTimeout` **[number][8]?** default timeout for wait* actions, in seconds.
|
|
84
84
|
* `waitForAction` **[number][8]?** fixed delay after each action, in milliseconds. When unset, actions wait only for the navigation they trigger.
|
|
85
85
|
* `pollInterval` **[number][8]?** interval between checks while waiting, in milliseconds.
|
|
@@ -190,6 +190,10 @@ I.dontSee('#add-to-cart-btn');
|
|
|
190
190
|
|
|
191
191
|
Returns **void** automatically synchronized promise through #recorder
|
|
192
192
|
|
|
193
|
+
### capabilities
|
|
194
|
+
|
|
195
|
+
Type: CodeceptJS.HelperCapabilities
|
|
196
|
+
|
|
193
197
|
### checkOption
|
|
194
198
|
|
|
195
199
|
Selects a checkbox or radio button.
|
|
@@ -683,6 +687,22 @@ I.forceClick({css: 'nav a.login'});
|
|
|
683
687
|
|
|
684
688
|
Returns **void** automatically synchronized promise through #recorder
|
|
685
689
|
|
|
690
|
+
### grabAriaSnapshot
|
|
691
|
+
|
|
692
|
+
Retrieves the ARIA snapshot of the page, or of an element, built from the browser accessibility tree.
|
|
693
|
+
The format matches Playwright's [ARIA snapshots][14].
|
|
694
|
+
|
|
695
|
+
```js
|
|
696
|
+
const snapshot = await I.grabAriaSnapshot();
|
|
697
|
+
const formSnapshot = await I.grabAriaSnapshot('#login-form');
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
#### Parameters
|
|
701
|
+
|
|
702
|
+
* `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator. Defaults to body element.
|
|
703
|
+
|
|
704
|
+
Returns **[Promise][12]<[string][3]>** YAML representation of the accessibility tree
|
|
705
|
+
|
|
686
706
|
### grabAttributeFrom
|
|
687
707
|
|
|
688
708
|
Retrieves an attribute from an element located by CSS or XPath and returns it to test.
|
|
@@ -714,7 +734,7 @@ let hints = await I.grabAttributeFromAll('.tooltip', 'title');
|
|
|
714
734
|
* `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
715
735
|
* `attr` **[string][3]** attribute name.
|
|
716
736
|
|
|
717
|
-
Returns **[Promise][12]<[Array][
|
|
737
|
+
Returns **[Promise][12]<[Array][15]<[string][3]>>** attribute value
|
|
718
738
|
|
|
719
739
|
### grabCookie
|
|
720
740
|
|
|
@@ -742,7 +762,7 @@ Resumes test execution, so **should be used inside async function with `await`**
|
|
|
742
762
|
let cookies = await I.grabCookies();
|
|
743
763
|
```
|
|
744
764
|
|
|
745
|
-
Returns **[Promise][12]<[Array][
|
|
765
|
+
Returns **[Promise][12]<[Array][15]<CodeceptJS.Cookie>>** array of cookie objects.
|
|
746
766
|
|
|
747
767
|
### grabCssPropertyFrom
|
|
748
768
|
|
|
@@ -775,7 +795,7 @@ const values = await I.grabCssPropertyFromAll('h3', 'font-weight');
|
|
|
775
795
|
* `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
776
796
|
* `cssProperty` **[string][3]** CSS property name.
|
|
777
797
|
|
|
778
|
-
Returns **[Promise][12]<[Array][
|
|
798
|
+
Returns **[Promise][12]<[Array][15]<[string][3]>>** CSS value
|
|
779
799
|
|
|
780
800
|
### grabCurrentUrl
|
|
781
801
|
|
|
@@ -835,7 +855,7 @@ let postHTMLs = await I.grabHTMLFromAll('.post');
|
|
|
835
855
|
* `locator`  
|
|
836
856
|
* `element` **([string][3] | [object][4])** located by CSS|XPath|strict locator.
|
|
837
857
|
|
|
838
|
-
Returns **[Promise][12]<[Array][
|
|
858
|
+
Returns **[Promise][12]<[Array][15]<[string][3]>>** HTML code for an element
|
|
839
859
|
|
|
840
860
|
### grabNumberOfElements
|
|
841
861
|
|
|
@@ -889,7 +909,7 @@ expect(traffics[0].response.status).to.equal(200);
|
|
|
889
909
|
expect(traffics[0].response.body).to.contain({ name: 'this was mocked' });
|
|
890
910
|
```
|
|
891
911
|
|
|
892
|
-
Returns **[Array][
|
|
912
|
+
Returns **[Array][15]** recorded network traffics
|
|
893
913
|
|
|
894
914
|
### grabSource
|
|
895
915
|
|
|
@@ -932,7 +952,7 @@ let pins = await I.grabTextFromAll('#pin li');
|
|
|
932
952
|
|
|
933
953
|
* `locator` **([string][3] | [object][4])** element located by CSS|XPath|strict locator.
|
|
934
954
|
|
|
935
|
-
Returns **[Promise][12]<[Array][
|
|
955
|
+
Returns **[Promise][12]<[Array][15]<[string][3]>>** attribute value
|
|
936
956
|
|
|
937
957
|
### grabTitle
|
|
938
958
|
|
|
@@ -974,7 +994,7 @@ let inputs = await I.grabValueFromAll('//form/input');
|
|
|
974
994
|
|
|
975
995
|
* `locator` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
976
996
|
|
|
977
|
-
Returns **[Promise][12]<[Array][
|
|
997
|
+
Returns **[Promise][12]<[Array][15]<[string][3]>>** attribute value
|
|
978
998
|
|
|
979
999
|
### grabWebElement
|
|
980
1000
|
|
|
@@ -1017,7 +1037,7 @@ I.pressKey(['Control', 'a']);
|
|
|
1017
1037
|
|
|
1018
1038
|
#### Parameters
|
|
1019
1039
|
|
|
1020
|
-
* `key` **([string][3] | [Array][
|
|
1040
|
+
* `key` **([string][3] | [Array][15]<[string][3]>)** a key or an array of keys to combine (modifiers first).
|
|
1021
1041
|
|
|
1022
1042
|
Returns **void** automatically synchronized promise through #recorder
|
|
1023
1043
|
|
|
@@ -1471,7 +1491,7 @@ I.selectOption('Which OS do you use?', ['Android', 'iOS']);
|
|
|
1471
1491
|
#### Parameters
|
|
1472
1492
|
|
|
1473
1493
|
* `select` **([string][3] | [object][4])** field located by label|name|CSS|XPath|strict locator.
|
|
1474
|
-
* `option` **([string][3] | [Array][
|
|
1494
|
+
* `option` **([string][3] | [Array][15]<any>)** visible text or value of option.
|
|
1475
1495
|
* `context` **([string][3]? | [object][4])** (optional, `null` by default) element located by CSS | XPath | strict locator.
|
|
1476
1496
|
|
|
1477
1497
|
Returns **void** automatically synchronized promise through #recorder
|
|
@@ -1494,7 +1514,7 @@ I.setCookie([
|
|
|
1494
1514
|
|
|
1495
1515
|
#### Parameters
|
|
1496
1516
|
|
|
1497
|
-
* `cookie` **(Cookie | [Array][
|
|
1517
|
+
* `cookie` **(Cookie | [Array][15]<Cookie>)** a cookie object or array of cookie objects.
|
|
1498
1518
|
|
|
1499
1519
|
Returns **void** automatically synchronized promise through #recorder
|
|
1500
1520
|
|
|
@@ -1544,13 +1564,13 @@ const video = await I.stopScreencast();
|
|
|
1544
1564
|
|
|
1545
1565
|
* `options` **[object][4]?** `{ lastFrameDelayMs }`: how long the last frame is shown, in milliseconds (1000 by default).
|
|
1546
1566
|
|
|
1547
|
-
Returns **[Promise][12]<([Buffer][
|
|
1567
|
+
Returns **[Promise][12]<([Buffer][16] | null)>** APNG data, or `null` if no frames were recorded.
|
|
1548
1568
|
|
|
1549
1569
|
### type
|
|
1550
1570
|
|
|
1551
1571
|
Types out the given text into an active field.
|
|
1552
1572
|
To slow down typing use a second parameter, to set interval between key presses.
|
|
1553
|
-
*Note:* Should be used when [`fillField`][
|
|
1573
|
+
*Note:* Should be used when [`fillField`][17] is not an option.
|
|
1554
1574
|
|
|
1555
1575
|
```js
|
|
1556
1576
|
// passing in a string
|
|
@@ -1570,7 +1590,7 @@ I.type(secret('123456'));
|
|
|
1570
1590
|
|
|
1571
1591
|
* `keys`  
|
|
1572
1592
|
* `delay` **[number][8]?** (optional) delay in ms between key presses
|
|
1573
|
-
* `key` **([string][3] | [Array][
|
|
1593
|
+
* `key` **([string][3] | [Array][15]<[string][3]>)** or array of keys to type.
|
|
1574
1594
|
|
|
1575
1595
|
Returns **void** automatically synchronized promise through #recorder
|
|
1576
1596
|
|
|
@@ -1690,7 +1710,7 @@ I.waitForFunction((count) => window.requests == count, [3], 5) // pass args and
|
|
|
1690
1710
|
#### Parameters
|
|
1691
1711
|
|
|
1692
1712
|
* `fn` **([string][3] | [function][11])** to be executed in browser context.
|
|
1693
|
-
* `argsOrSec` **([Array][
|
|
1713
|
+
* `argsOrSec` **([Array][15]<any> | [number][8])?** (optional, `1` by default) arguments for function or seconds.
|
|
1694
1714
|
* `sec` **[number][8]?** (optional, `1` by default) time in seconds to wait
|
|
1695
1715
|
|
|
1696
1716
|
Returns **void** automatically synchronized promise through #recorder
|
|
@@ -1835,7 +1855,7 @@ Probes a `/json/version`-style URL with a short timeout, used for the courtesy-a
|
|
|
1835
1855
|
|
|
1836
1856
|
* `url` **[string][3]** 
|
|
1837
1857
|
|
|
1838
|
-
Returns **[Promise][12]<[boolean][
|
|
1858
|
+
Returns **[Promise][12]<[boolean][18]>** true if the URL answered.
|
|
1839
1859
|
|
|
1840
1860
|
### _resolveBinary
|
|
1841
1861
|
|
|
@@ -1892,10 +1912,12 @@ per run and counts directly toward real-world startup latency.
|
|
|
1892
1912
|
|
|
1893
1913
|
[13]: https://playwright.dev/docs/api/class-locator#locator-focus
|
|
1894
1914
|
|
|
1895
|
-
[14]: https://
|
|
1915
|
+
[14]: https://playwright.dev/docs/aria-snapshots
|
|
1916
|
+
|
|
1917
|
+
[15]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
1896
1918
|
|
|
1897
|
-
[
|
|
1919
|
+
[16]: https://nodejs.org/api/buffer.html
|
|
1898
1920
|
|
|
1899
|
-
[
|
|
1921
|
+
[17]: #fillfield
|
|
1900
1922
|
|
|
1901
|
-
[
|
|
1923
|
+
[18]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
|