codeceptjs 4.0.0-rc.23 → 4.0.0-rc.24
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 +9 -10
- package/docs/ai.md +3 -51
- package/docs/architecture.md +16 -0
- package/docs/bootstrap.md +1 -1
- package/docs/continuous-integration.md +16 -44
- package/docs/custom-helpers.md +1 -1
- package/docs/detox.md +1 -1
- package/docs/docker.md +1 -30
- package/docs/examples.md +0 -1
- package/docs/helpers/Appium.md +16 -2
- package/docs/helpers/Playwright.md +161 -160
- package/docs/helpers/Puppeteer.md +143 -250
- package/docs/helpers/WebDriver.md +134 -177
- package/docs/hooks.md +11 -1
- package/docs/index.md +1 -1
- package/docs/installation.md +2 -19
- package/docs/locators.md +1 -1
- package/docs/migrate-from-cypress.md +98 -0
- package/docs/migrate-from-java.md +108 -0
- package/docs/migrate-from-protractor.md +101 -0
- package/docs/migrate-from-testcafe.md +99 -0
- package/docs/migration-4.md +195 -8
- package/docs/plugins/aiTrace.md +49 -0
- package/docs/plugins/analyze.md +66 -0
- package/docs/plugins/auth.md +241 -0
- package/docs/plugins/autoDelay.md +48 -0
- package/docs/plugins/browser.md +41 -0
- package/docs/plugins/coverage.md +39 -0
- package/docs/plugins/customLocator.md +119 -0
- package/docs/plugins/customReporter.md +16 -0
- package/docs/plugins/expose.md +75 -0
- package/docs/plugins/heal.md +44 -0
- package/docs/plugins/junitReporter.md +51 -0
- package/docs/plugins/pageInfo.md +34 -0
- package/docs/plugins/pause.md +43 -0
- package/docs/plugins/pauseOnFail.md +18 -0
- package/docs/plugins/retryFailedStep.md +75 -0
- package/docs/plugins/screencast.md +55 -0
- package/docs/plugins/screenshot.md +58 -0
- package/docs/plugins/screenshotOnFail.md +18 -0
- package/docs/plugins/stepTimeout.md +65 -0
- package/docs/plugins.md +40 -862
- package/docs/reports.md +18 -4
- package/docs/retry.md +48 -18
- package/docs/store.md +94 -0
- package/docs/timeouts.md +1 -1
- package/docs/tutorial.md +207 -155
- package/docs/webdriver.md +6 -73
- package/lib/actor.js +0 -35
- package/lib/command/run-multiple.js +1 -2
- package/lib/helper/Playwright.js +1 -15
- package/lib/helper/Puppeteer.js +0 -103
- package/lib/helper/WebDriver.js +1 -28
- package/lib/helper/extras/PlaywrightLocator.js +10 -0
- package/lib/locator.js +0 -13
- package/lib/plugin/analyze.js +3 -4
- package/lib/plugin/pauseOnFail.js +3 -1
- package/lib/plugin/retryFailedStep.js +7 -7
- package/lib/plugin/screenshot.js +0 -5
- package/lib/plugin/screenshotOnFail.js +3 -1
- package/lib/plugin/stepTimeout.js +1 -1
- package/lib/recorder.js +1 -1
- package/lib/workers.js +0 -4
- package/package.json +3 -4
- package/docs/helpers/Mochawesome.md +0 -8
- package/docs/helpers/MockServer.md +0 -212
- package/docs/helpers/Polly.md +0 -44
- package/docs/helpers/Protractor.md +0 -1769
- package/docs/helpers/SoftExpectHelper.md +0 -352
- package/docs/react.md +0 -70
- package/lib/helper/Mochawesome.js +0 -96
- package/lib/helper/extras/PlaywrightReactVueLocator.js +0 -61
- package/lib/helper/extras/React.js +0 -65
package/lib/workers.js
CHANGED
|
@@ -118,11 +118,9 @@ const createWorkerObjects = (testGroups, config, testRoot, options, selectedRuns
|
|
|
118
118
|
const workersToExecute = []
|
|
119
119
|
|
|
120
120
|
const currentOutputFolder = config.output
|
|
121
|
-
let currentMochawesomeReportDir
|
|
122
121
|
let currentMochaJunitReporterFile
|
|
123
122
|
|
|
124
123
|
if (config.mocha && config.mocha.reporterOptions) {
|
|
125
|
-
currentMochawesomeReportDir = config.mocha.reporterOptions?.mochawesome.options.reportDir
|
|
126
124
|
currentMochaJunitReporterFile = config.mocha.reporterOptions['mocha-junit-reporter'].options.mochaFile
|
|
127
125
|
}
|
|
128
126
|
|
|
@@ -132,8 +130,6 @@ const createWorkerObjects = (testGroups, config, testRoot, options, selectedRuns
|
|
|
132
130
|
let workerName = worker.name.replace(':', '_')
|
|
133
131
|
_config.output = `${currentOutputFolder}${separator}${workerName}`
|
|
134
132
|
if (config.mocha && config.mocha.reporterOptions) {
|
|
135
|
-
_config.mocha.reporterOptions.mochawesome.options.reportDir = `${currentMochawesomeReportDir}${separator}${workerName}`
|
|
136
|
-
|
|
137
133
|
const _tempArray = currentMochaJunitReporterFile.split(separator)
|
|
138
134
|
_tempArray.splice(
|
|
139
135
|
_tempArray.findIndex(item => item.includes('.xml')),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codeceptjs",
|
|
3
|
-
"version": "4.0.0-rc.
|
|
3
|
+
"version": "4.0.0-rc.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Supercharged End 2 End Testing Framework for NodeJS",
|
|
6
6
|
"keywords": [
|
|
@@ -27,7 +27,8 @@
|
|
|
27
27
|
"translations",
|
|
28
28
|
"typings/**/*.d.ts",
|
|
29
29
|
"docs/*.md",
|
|
30
|
-
"docs/helpers/**"
|
|
30
|
+
"docs/helpers/**",
|
|
31
|
+
"docs/plugins/**"
|
|
31
32
|
],
|
|
32
33
|
"main": "lib/index.js",
|
|
33
34
|
"module": "lib/index.js",
|
|
@@ -130,7 +131,6 @@
|
|
|
130
131
|
"parse-function": "5.6.10",
|
|
131
132
|
"parse5": "7.3.0",
|
|
132
133
|
"promise-retry": "1.1.1",
|
|
133
|
-
"resq": "1.11.0",
|
|
134
134
|
"sprintf-js": "1.1.3",
|
|
135
135
|
"uuid": "11.1.0",
|
|
136
136
|
"xpath": "0.0.34",
|
|
@@ -175,7 +175,6 @@
|
|
|
175
175
|
"jsdoc": "^3.6.11",
|
|
176
176
|
"jsdoc-typeof-plugin": "1.0.0",
|
|
177
177
|
"json-server": "0.17.4",
|
|
178
|
-
"mochawesome": "^7.1.3",
|
|
179
178
|
"playwright": "^1.59.0",
|
|
180
179
|
"prettier": "^3.3.2",
|
|
181
180
|
"puppeteer": "24.36.0",
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
permalink: /helpers/MockServer
|
|
3
|
-
editLink: false
|
|
4
|
-
sidebar: auto
|
|
5
|
-
title: MockServer
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
9
|
-
|
|
10
|
-
## MockServer
|
|
11
|
-
|
|
12
|
-
MockServer
|
|
13
|
-
|
|
14
|
-
The MockServer Helper in CodeceptJS empowers you to mock any server or service via HTTP or HTTPS, making it an excellent tool for simulating REST endpoints and other HTTP-based APIs.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
## Configuration
|
|
19
|
-
|
|
20
|
-
This helper should be configured in codecept.conf.(js|ts)
|
|
21
|
-
|
|
22
|
-
Type: [object][1]
|
|
23
|
-
|
|
24
|
-
### Properties
|
|
25
|
-
|
|
26
|
-
- `port` **[number][2]?** Mock server port
|
|
27
|
-
- `host` **[string][3]?** Mock server host
|
|
28
|
-
- `httpsOpts` **[object][1]?** key & cert values are the paths to .key and .crt files
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
#### Examples
|
|
33
|
-
|
|
34
|
-
You can seamlessly integrate MockServer with other helpers like REST or Playwright. Here's a configuration example inside the `codecept.conf.js` file:
|
|
35
|
-
|
|
36
|
-
```javascript
|
|
37
|
-
{
|
|
38
|
-
helpers: {
|
|
39
|
-
REST: {...},
|
|
40
|
-
MockServer: {
|
|
41
|
-
// default mock server config
|
|
42
|
-
port: 9393,
|
|
43
|
-
host: '0.0.0.0',
|
|
44
|
-
httpsOpts: {
|
|
45
|
-
key: '',
|
|
46
|
-
cert: '',
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
#### Adding Interactions
|
|
54
|
-
|
|
55
|
-
Interactions add behavior to the mock server. Use the `I.addInteractionToMockServer()` method to include interactions. It takes an interaction object as an argument, containing request and response details.
|
|
56
|
-
|
|
57
|
-
```javascript
|
|
58
|
-
I.addInteractionToMockServer({
|
|
59
|
-
request: {
|
|
60
|
-
method: 'GET',
|
|
61
|
-
path: '/api/hello'
|
|
62
|
-
},
|
|
63
|
-
response: {
|
|
64
|
-
status: 200,
|
|
65
|
-
body: {
|
|
66
|
-
'say': 'hello to mock server'
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
#### Request Matching
|
|
73
|
-
|
|
74
|
-
When a real request is sent to the mock server, it matches the received request with the interactions. If a match is found, it returns the specified response; otherwise, a 404 status code is returned.
|
|
75
|
-
|
|
76
|
-
- Strong match on HTTP Method, Path, Query Params & JSON body.
|
|
77
|
-
- Loose match on Headers.
|
|
78
|
-
|
|
79
|
-
##### Strong Match on Query Params
|
|
80
|
-
|
|
81
|
-
You can send different responses based on query parameters:
|
|
82
|
-
|
|
83
|
-
```javascript
|
|
84
|
-
I.addInteractionToMockServer({
|
|
85
|
-
request: {
|
|
86
|
-
method: 'GET',
|
|
87
|
-
path: '/api/users',
|
|
88
|
-
queryParams: {
|
|
89
|
-
id: 1
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
response: {
|
|
93
|
-
status: 200,
|
|
94
|
-
body: 'user 1'
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
I.addInteractionToMockServer({
|
|
99
|
-
request: {
|
|
100
|
-
method: 'GET',
|
|
101
|
-
path: '/api/users',
|
|
102
|
-
queryParams: {
|
|
103
|
-
id: 2
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
response: {
|
|
107
|
-
status: 200,
|
|
108
|
-
body: 'user 2'
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
- GET to `/api/users?id=1` will return 'user 1'.
|
|
114
|
-
- GET to `/api/users?id=2` will return 'user 2'.
|
|
115
|
-
- For all other requests, it returns a 404 status code.
|
|
116
|
-
|
|
117
|
-
##### Loose Match on Body
|
|
118
|
-
|
|
119
|
-
When `strict` is set to false, it performs a loose match on query params and response body:
|
|
120
|
-
|
|
121
|
-
```javascript
|
|
122
|
-
I.addInteractionToMockServer({
|
|
123
|
-
strict: false,
|
|
124
|
-
request: {
|
|
125
|
-
method: 'POST',
|
|
126
|
-
path: '/api/users',
|
|
127
|
-
body: {
|
|
128
|
-
name: 'john'
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
response: {
|
|
132
|
-
status: 200
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
- POST to `/api/users` with the body containing `name` as 'john' will return a 200 status code.
|
|
138
|
-
- POST to `/api/users` without the `name` property in the body will return a 404 status code.
|
|
139
|
-
|
|
140
|
-
Happy testing with MockServer in CodeceptJS! 🚀
|
|
141
|
-
|
|
142
|
-
## Methods
|
|
143
|
-
|
|
144
|
-
### Parameters
|
|
145
|
-
|
|
146
|
-
- `passedConfig`
|
|
147
|
-
|
|
148
|
-
### addInteractionToMockServer
|
|
149
|
-
|
|
150
|
-
An interaction adds behavior to the mock server
|
|
151
|
-
|
|
152
|
-
```js
|
|
153
|
-
I.addInteractionToMockServer({
|
|
154
|
-
request: {
|
|
155
|
-
method: 'GET',
|
|
156
|
-
path: '/api/hello'
|
|
157
|
-
},
|
|
158
|
-
response: {
|
|
159
|
-
status: 200,
|
|
160
|
-
body: {
|
|
161
|
-
'say': 'hello to mock server'
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
```js
|
|
168
|
-
// with query params
|
|
169
|
-
I.addInteractionToMockServer({
|
|
170
|
-
request: {
|
|
171
|
-
method: 'GET',
|
|
172
|
-
path: '/api/hello',
|
|
173
|
-
queryParams: {
|
|
174
|
-
id: 2
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
response: {
|
|
178
|
-
status: 200,
|
|
179
|
-
body: {
|
|
180
|
-
'say': 'hello to mock server'
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
```
|
|
185
|
-
|
|
186
|
-
#### Parameters
|
|
187
|
-
|
|
188
|
-
- `interaction` **(CodeceptJS.MockInteraction | [object][1])** add behavior to the mock server
|
|
189
|
-
|
|
190
|
-
Returns **any** void
|
|
191
|
-
|
|
192
|
-
### startMockServer
|
|
193
|
-
|
|
194
|
-
Start the mock server
|
|
195
|
-
|
|
196
|
-
#### Parameters
|
|
197
|
-
|
|
198
|
-
- `port` **[number][2]?** start the mock server with given port
|
|
199
|
-
|
|
200
|
-
Returns **any** void
|
|
201
|
-
|
|
202
|
-
### stopMockServer
|
|
203
|
-
|
|
204
|
-
Stop the mock server
|
|
205
|
-
|
|
206
|
-
Returns **any** void
|
|
207
|
-
|
|
208
|
-
[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
|
|
209
|
-
|
|
210
|
-
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
|
|
211
|
-
|
|
212
|
-
[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
|
package/docs/helpers/Polly.md
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
id: Polly
|
|
3
|
-
title: Polly
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
7
|
-
|
|
8
|
-
## Polly
|
|
9
|
-
|
|
10
|
-
**Extends MockRequest**
|
|
11
|
-
|
|
12
|
-
This helper works the same as MockRequest helper. It has been included for backwards compatibility
|
|
13
|
-
reasons. So use MockRequest helper instead of this.
|
|
14
|
-
|
|
15
|
-
Please refer to MockRequest helper documentation for details.
|
|
16
|
-
|
|
17
|
-
### Installations
|
|
18
|
-
|
|
19
|
-
Requires [Polly.js][1] library by Netflix installed
|
|
20
|
-
|
|
21
|
-
npm i @pollyjs/core @pollyjs/adapter-puppeteer --save-dev
|
|
22
|
-
|
|
23
|
-
Requires Puppeteer helper or WebDriver helper enabled
|
|
24
|
-
|
|
25
|
-
### Configuration
|
|
26
|
-
|
|
27
|
-
Just enable helper in config file:
|
|
28
|
-
|
|
29
|
-
```js
|
|
30
|
-
helpers: {
|
|
31
|
-
Puppeteer: {
|
|
32
|
-
// regular Puppeteer config here
|
|
33
|
-
},
|
|
34
|
-
Polly: {}
|
|
35
|
-
}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
The same can be done when using WebDriver helper..
|
|
39
|
-
|
|
40
|
-
### Usage
|
|
41
|
-
|
|
42
|
-
Use `I.mockRequest` to intercept and mock requests.
|
|
43
|
-
|
|
44
|
-
[1]: https://netflix.github.io/pollyjs/#/
|