codeceptjs 4.2.0 → 4.2.1-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/README.md +2 -0
- package/bin/codecept.js +11 -0
- package/docs/agents.md +26 -1
- package/docs/ai.md +57 -0
- package/docs/alternative-browsers.md +175 -148
- package/docs/assertions.md +74 -0
- package/docs/bootstrap.md +2 -0
- package/docs/commands.md +45 -0
- package/docs/configuration.md +37 -0
- package/docs/debugging.md +1 -1
- package/docs/helpers/ApiDataFactory.md +20 -20
- package/docs/helpers/Appium.md +1615 -670
- package/docs/helpers/Decision.md +146 -0
- package/docs/helpers/GraphQL.md +31 -31
- package/docs/helpers/GraphQLDataFactory.md +20 -20
- package/docs/helpers/Kitesurf.md +1808 -25
- package/docs/helpers/Lightpanda.md +139 -0
- package/docs/helpers/Obscura.md +1799 -74
- package/docs/helpers/Playwright.md +490 -428
- package/docs/helpers/Puppeteer.md +317 -255
- package/docs/helpers/REST.md +43 -43
- package/docs/helpers/WebDriver.md +237 -175
- package/docs/installation.md +16 -0
- package/docs/mcp.md +7 -1
- package/docs/parallel.md +35 -1
- package/docs/plugins/pause.md +2 -1
- package/docs/plugins/sitemap.md +48 -0
- package/docs/plugins.md +4 -0
- package/lib/ai.js +81 -2
- package/lib/codecept.js +32 -2
- package/lib/command/init.js +22 -0
- package/lib/command/initAgent.js +78 -0
- package/lib/command/run-multiple.js +3 -0
- package/lib/command/run-workers.js +10 -3
- package/lib/command/run.js +3 -2
- package/lib/command/utils.js +15 -0
- package/lib/command/workers/runTests.js +10 -10
- package/lib/container.js +4 -2
- package/lib/effects.js +19 -1
- package/lib/helper/CDPBrowser.js +349 -1384
- package/lib/helper/Decision.js +256 -0
- package/lib/helper/Kitesurf.js +3 -21
- package/lib/helper/Lightpanda.js +137 -0
- package/lib/helper/Obscura.js +21 -238
- package/lib/helper/Playwright.js +6 -4
- package/lib/helper/Puppeteer.js +12 -7
- package/lib/helper/WebDriver.js +2 -1
- package/lib/listener/result.js +4 -0
- package/lib/mocha/bdd.js +19 -1
- package/lib/plugin/junitReporter.js +4 -1
- package/lib/plugin/pause.js +4 -1
- package/lib/plugin/sitemap.js +228 -0
- package/lib/recorder.js +19 -18
- package/lib/result.js +16 -0
- package/lib/step/base.js +12 -0
- package/lib/utils.js +2 -10
- package/lib/webServer.js +193 -0
- package/lib/workers.js +118 -31
- package/package.json +4 -2
- package/typings/index.d.ts +60 -7
- package/typings/promiseBasedTypes.d.ts +772 -824
- package/typings/types.d.ts +866 -833
- package/docs/helpers/CDPBrowser.md +0 -2138
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
---
|
|
2
|
+
permalink: /helpers/Decision
|
|
3
|
+
editLink: false
|
|
4
|
+
sidebar: auto
|
|
5
|
+
title: Decision
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
9
|
+
|
|
10
|
+
## Decision
|
|
11
|
+
|
|
12
|
+
**Extends Helper**
|
|
13
|
+
|
|
14
|
+
Asserts statements about the current page with a decision model.
|
|
15
|
+
|
|
16
|
+
Decision models (like [Jev][1] or [Clef][2])
|
|
17
|
+
do not generate text. They read the page state and return the probability that a statement is true.
|
|
18
|
+
A statement passes when its probability reaches the configured `confidence`.
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
I.decide('top level navigation is available');
|
|
22
|
+
I.decide([
|
|
23
|
+
'checkout form has all required fields',
|
|
24
|
+
'success message is shown',
|
|
25
|
+
'submit button enabled',
|
|
26
|
+
'cancel button present',
|
|
27
|
+
]);
|
|
28
|
+
I.decideVisually('sidebar is shown');
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The model receives the page URL, title and ARIA snapshot.
|
|
32
|
+
Helpers without ARIA snapshots (anything but Playwright) send minified HTML instead.
|
|
33
|
+
`decideVisually` also sends a screenshot, so it requires a model with image input.
|
|
34
|
+
|
|
35
|
+
This helper must be enabled together with a web helper (Playwright, Puppeteer, WebDriver).
|
|
36
|
+
|
|
37
|
+
## Configuration
|
|
38
|
+
|
|
39
|
+
Decision model is created with the OpenRouter provider from `@openrouter/ai-sdk-provider`
|
|
40
|
+
and configured in the `ai.decisionModel` section of the config:
|
|
41
|
+
|
|
42
|
+
```js
|
|
43
|
+
import { createOpenRouter } from '@openrouter/ai-sdk-provider'
|
|
44
|
+
|
|
45
|
+
const openrouter = createOpenRouter({
|
|
46
|
+
apiKey: process.env.OPENROUTER_API_KEY,
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
export default {
|
|
50
|
+
ai: {
|
|
51
|
+
decisionModel: {
|
|
52
|
+
model: openrouter.evaluationModel('typesafe/jev-1.13'),
|
|
53
|
+
confidence: 0.8,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
helpers: {
|
|
57
|
+
Playwright: { url: 'http://localhost' },
|
|
58
|
+
Decision: {},
|
|
59
|
+
},
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
* `model` - decision model used by `decide`.
|
|
64
|
+
* `confidence` (default: `0.7`) - minimal probability, between 0 and 1, for a statement to pass.
|
|
65
|
+
* `timeout` (default: `15000`) - request timeout in ms.
|
|
66
|
+
* `maxLength` (default: `12000`) - maximal length of ARIA snapshot or HTML sent to the model.
|
|
67
|
+
|
|
68
|
+
`decideVisually` uses a separate decision model with image input, configured as `visualModel`:
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
decisionModel: {
|
|
72
|
+
model: openrouter.evaluationModel('typesafe/jev-1.13'),
|
|
73
|
+
visualModel: openrouter.evaluationModel('cloudflare/clef'),
|
|
74
|
+
},
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
The helper has one option:
|
|
78
|
+
|
|
79
|
+
* `mode` (default: `assert`) - how decisions are executed:
|
|
80
|
+
* `assert` - request the model and fail the step when a statement is not confirmed.
|
|
81
|
+
* `report` - request the model but never fail, even on API errors. Results and errors are added to the step as a comment.
|
|
82
|
+
* `skip` - do not request the model, every decision passes.
|
|
83
|
+
|
|
84
|
+
```js
|
|
85
|
+
Decision: { mode: process.env.CI ? 'assert' : 'skip' }
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Decisions work without the `--ai` flag.
|
|
89
|
+
Browse all decision models at [OpenRouter][3].
|
|
90
|
+
|
|
91
|
+
## Methods
|
|
92
|
+
|
|
93
|
+
### Parameters
|
|
94
|
+
|
|
95
|
+
* `config`
|
|
96
|
+
|
|
97
|
+
### decide
|
|
98
|
+
|
|
99
|
+
Asserts that a statement (or each of statements) is true for the current page.
|
|
100
|
+
The decision model receives page URL, title and ARIA snapshot.
|
|
101
|
+
Multiple statements are checked in a single request and all of them must pass.
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
I.decide('user is logged in');
|
|
105
|
+
I.decide(['submit button enabled', 'cancel button present']);
|
|
106
|
+
const probability = await I.decide('cart is empty');
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### Parameters
|
|
110
|
+
|
|
111
|
+
* `statements` **([string][4] | [Array][5]<[string][4]>)** statement or list of statements to verify.
|
|
112
|
+
|
|
113
|
+
Returns **[Promise][6]<([number][7] | [Array][5]<[number][7]> | [undefined][8])>** probability of each statement, `undefined` in `skip` mode.
|
|
114
|
+
|
|
115
|
+
### decideVisually
|
|
116
|
+
|
|
117
|
+
Asserts that a statement (or each of statements) is true for the current page using a screenshot.
|
|
118
|
+
The decision model receives page URL, title, ARIA snapshot and a screenshot.
|
|
119
|
+
Requires `visualModel` with image input. Experimental.
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
I.decideVisually('sidebar is shown');
|
|
123
|
+
I.decideVisually(['logo is in the header', 'page uses dark theme']);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### Parameters
|
|
127
|
+
|
|
128
|
+
* `statements` **([string][4] | [Array][5]<[string][4]>)** statement or list of statements to verify.
|
|
129
|
+
|
|
130
|
+
Returns **[Promise][6]<([number][7] | [Array][5]<[number][7]> | [undefined][8])>** probability of each statement, `undefined` in `skip` mode.
|
|
131
|
+
|
|
132
|
+
[1]: https://openrouter.ai/typesafe/jev-1.13
|
|
133
|
+
|
|
134
|
+
[2]: https://openrouter.ai/cloudflare/clef
|
|
135
|
+
|
|
136
|
+
[3]: https://openrouter.ai/models?output_modalities=decisions
|
|
137
|
+
|
|
138
|
+
[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
139
|
+
|
|
140
|
+
[5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array
|
|
141
|
+
|
|
142
|
+
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
|
|
143
|
+
|
|
144
|
+
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
145
|
+
|
|
146
|
+
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined
|
package/docs/helpers/GraphQL.md
CHANGED
|
@@ -49,25 +49,6 @@ this.helpers['GraphQL']._executeQuery({
|
|
|
49
49
|
|
|
50
50
|
* `config`  
|
|
51
51
|
|
|
52
|
-
### _executeQuery
|
|
53
|
-
|
|
54
|
-
Executes query via axios call
|
|
55
|
-
|
|
56
|
-
#### Parameters
|
|
57
|
-
|
|
58
|
-
* `request` **[object][2]** 
|
|
59
|
-
|
|
60
|
-
### _prepareGraphQLRequest
|
|
61
|
-
|
|
62
|
-
Prepares request for axios call
|
|
63
|
-
|
|
64
|
-
#### Parameters
|
|
65
|
-
|
|
66
|
-
* `operation` **[object][2]** 
|
|
67
|
-
* `headers` **[object][2]** 
|
|
68
|
-
|
|
69
|
-
Returns **[object][2]** graphQLRequest
|
|
70
|
-
|
|
71
52
|
### amBearerAuthenticated
|
|
72
53
|
|
|
73
54
|
Adds a header for Bearer authentication
|
|
@@ -79,7 +60,7 @@ I.amBearerAuthenticated(secret('heregoestoken'))
|
|
|
79
60
|
|
|
80
61
|
#### Parameters
|
|
81
62
|
|
|
82
|
-
* `accessToken` **([string][
|
|
63
|
+
* `accessToken` **([string][2] | CodeceptJS.Secret)** Bearer access token
|
|
83
64
|
|
|
84
65
|
### haveRequestHeaders
|
|
85
66
|
|
|
@@ -87,7 +68,7 @@ Sets request headers for all requests of this test
|
|
|
87
68
|
|
|
88
69
|
#### Parameters
|
|
89
70
|
|
|
90
|
-
* `headers` **[object][
|
|
71
|
+
* `headers` **[object][3]** headers list
|
|
91
72
|
|
|
92
73
|
### sendMutation
|
|
93
74
|
|
|
@@ -113,10 +94,10 @@ I.sendMutation(`
|
|
|
113
94
|
|
|
114
95
|
#### Parameters
|
|
115
96
|
|
|
116
|
-
* `mutation` **[String][
|
|
117
|
-
* `variables` **[object][
|
|
118
|
-
* `options` **[object][
|
|
119
|
-
* `headers` **[object][
|
|
97
|
+
* `mutation` **[String][2]** 
|
|
98
|
+
* `variables` **[object][3]?** that may go along with the mutation
|
|
99
|
+
* `options` **[object][3]?** are additional query options
|
|
100
|
+
* `headers` **[object][3]?**
|
|
120
101
|
|
|
121
102
|
Returns **any** Promise<any>
|
|
122
103
|
|
|
@@ -138,15 +119,34 @@ const user = response.data.data;
|
|
|
138
119
|
|
|
139
120
|
#### Parameters
|
|
140
121
|
|
|
141
|
-
* `query` **[String][
|
|
142
|
-
* `variables` **[object][
|
|
143
|
-
* `options` **[object][
|
|
144
|
-
* `headers` **[object][
|
|
122
|
+
* `query` **[String][2]** 
|
|
123
|
+
* `variables` **[object][3]?** that may go along with the query
|
|
124
|
+
* `options` **[object][3]?** are additional query options
|
|
125
|
+
* `headers` **[object][3]?**
|
|
145
126
|
|
|
146
127
|
Returns **any** Promise<any>
|
|
147
128
|
|
|
129
|
+
### _executeQuery
|
|
130
|
+
|
|
131
|
+
Executes query via axios call
|
|
132
|
+
|
|
133
|
+
#### Parameters
|
|
134
|
+
|
|
135
|
+
* `request` **[object][3]** 
|
|
136
|
+
|
|
137
|
+
### _prepareGraphQLRequest
|
|
138
|
+
|
|
139
|
+
Prepares request for axios call
|
|
140
|
+
|
|
141
|
+
#### Parameters
|
|
142
|
+
|
|
143
|
+
* `operation` **[object][3]** 
|
|
144
|
+
* `headers` **[object][3]** 
|
|
145
|
+
|
|
146
|
+
Returns **[object][3]** graphQLRequest
|
|
147
|
+
|
|
148
148
|
[1]: https://github.com/axios/axios
|
|
149
149
|
|
|
150
|
-
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/
|
|
150
|
+
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
|
151
151
|
|
|
152
|
-
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/
|
|
152
|
+
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
@@ -160,26 +160,6 @@ Data of created records are collected and used in the end of a test for the clea
|
|
|
160
160
|
|
|
161
161
|
* `config`  
|
|
162
162
|
|
|
163
|
-
### _requestCreate
|
|
164
|
-
|
|
165
|
-
Executes request to create a record to the GraphQL endpoint.
|
|
166
|
-
Can be replaced from a custom helper.
|
|
167
|
-
|
|
168
|
-
#### Parameters
|
|
169
|
-
|
|
170
|
-
* `operation` **[string][4]** 
|
|
171
|
-
* `variables` **any** to be sent along with the query
|
|
172
|
-
|
|
173
|
-
### _requestDelete
|
|
174
|
-
|
|
175
|
-
Executes request to delete a record to the GraphQL endpoint.
|
|
176
|
-
Can be replaced from a custom helper.
|
|
177
|
-
|
|
178
|
-
#### Parameters
|
|
179
|
-
|
|
180
|
-
* `operation` **[string][4]** 
|
|
181
|
-
* `data` **any** of the record to be deleted.
|
|
182
|
-
|
|
183
163
|
### mutateData
|
|
184
164
|
|
|
185
165
|
Generates a new record using factory, sends a GraphQL mutation to store it.
|
|
@@ -215,6 +195,26 @@ I.mutateMultiple('createUser', 3, { age: 25 });
|
|
|
215
195
|
* `times` **[number][5]** 
|
|
216
196
|
* `params` **any** 
|
|
217
197
|
|
|
198
|
+
### _requestCreate
|
|
199
|
+
|
|
200
|
+
Executes request to create a record to the GraphQL endpoint.
|
|
201
|
+
Can be replaced from a custom helper.
|
|
202
|
+
|
|
203
|
+
#### Parameters
|
|
204
|
+
|
|
205
|
+
* `operation` **[string][4]** 
|
|
206
|
+
* `variables` **any** to be sent along with the query
|
|
207
|
+
|
|
208
|
+
### _requestDelete
|
|
209
|
+
|
|
210
|
+
Executes request to delete a record to the GraphQL endpoint.
|
|
211
|
+
Can be replaced from a custom helper.
|
|
212
|
+
|
|
213
|
+
#### Parameters
|
|
214
|
+
|
|
215
|
+
* `operation` **[string][4]** 
|
|
216
|
+
* `data` **any** of the record to be deleted.
|
|
217
|
+
|
|
218
218
|
[1]: https://github.com/rosiejs/rosie
|
|
219
219
|
|
|
220
220
|
[2]: https://www.npmjs.com/package/faker
|