codeceptjs 3.6.6 → 4.0.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/bin/codecept.js +81 -84
- package/lib/actor.js +13 -13
- package/lib/ai.js +13 -10
- package/lib/assert/empty.js +21 -20
- package/lib/assert/equal.js +39 -37
- package/lib/assert/error.js +14 -14
- package/lib/assert/include.js +47 -46
- package/lib/assert/throws.js +11 -13
- package/lib/assert/truth.js +22 -19
- package/lib/assert.js +2 -4
- package/lib/cli.js +49 -57
- package/lib/codecept.js +155 -142
- package/lib/colorUtils.js +3 -3
- package/lib/command/configMigrate.js +52 -58
- package/lib/command/definitions.js +89 -88
- package/lib/command/dryRun.js +68 -71
- package/lib/command/generate.js +188 -197
- package/lib/command/gherkin/init.js +16 -27
- package/lib/command/gherkin/snippets.js +20 -20
- package/lib/command/gherkin/steps.js +8 -8
- package/lib/command/info.js +38 -40
- package/lib/command/init.js +288 -290
- package/lib/command/interactive.js +32 -32
- package/lib/command/list.js +26 -26
- package/lib/command/run-multiple/chunk.js +5 -5
- package/lib/command/run-multiple/collection.js +3 -3
- package/lib/command/run-multiple/run.js +2 -6
- package/lib/command/run-multiple.js +93 -113
- package/lib/command/run-rerun.js +25 -20
- package/lib/command/run-workers.js +66 -64
- package/lib/command/run.js +29 -26
- package/lib/command/utils.js +65 -80
- package/lib/command/workers/runTests.js +10 -10
- package/lib/config.js +9 -10
- package/lib/container.js +48 -40
- package/lib/data/context.js +59 -60
- package/lib/data/dataScenarioConfig.js +47 -47
- package/lib/data/dataTableArgument.js +29 -29
- package/lib/data/table.js +20 -26
- package/lib/dirname.js +5 -0
- package/lib/event.js +167 -163
- package/lib/heal.js +17 -13
- package/lib/helper/AI.js +41 -130
- package/lib/helper/ApiDataFactory.js +69 -73
- package/lib/helper/Appium.js +381 -412
- package/lib/helper/Expect.js +425 -0
- package/lib/helper/ExpectHelper.js +48 -40
- package/lib/helper/FileSystem.js +79 -80
- package/lib/helper/GraphQL.js +43 -44
- package/lib/helper/GraphQLDataFactory.js +50 -50
- package/lib/helper/JSONResponse.js +62 -65
- package/lib/helper/Mochawesome.js +28 -28
- package/lib/helper/MockServer.js +14 -12
- package/lib/helper/Nightmare.js +566 -662
- package/lib/helper/Playwright.js +1216 -1361
- package/lib/helper/Protractor.js +627 -663
- package/lib/helper/Puppeteer.js +1128 -1231
- package/lib/helper/REST.js +68 -159
- package/lib/helper/SoftExpectHelper.js +2 -2
- package/lib/helper/TestCafe.js +484 -490
- package/lib/helper/WebDriver.js +1156 -1297
- package/lib/helper/clientscripts/PollyWebDriverExt.js +1 -1
- package/lib/helper/errors/ConnectionRefused.js +1 -1
- package/lib/helper/errors/ElementAssertion.js +2 -2
- package/lib/helper/errors/ElementNotFound.js +2 -2
- package/lib/helper/errors/RemoteBrowserConnectionRefused.js +1 -1
- package/lib/helper/extras/Console.js +1 -1
- package/lib/helper/extras/PlaywrightPropEngine.js +2 -2
- package/lib/helper/extras/PlaywrightReactVueLocator.js +1 -1
- package/lib/helper/extras/PlaywrightRestartOpts.js +18 -21
- package/lib/helper/extras/Popup.js +1 -1
- package/lib/helper/extras/React.js +3 -3
- package/lib/helper/network/actions.js +7 -14
- package/lib/helper/network/utils.js +2 -3
- package/lib/helper/scripts/blurElement.js +1 -1
- package/lib/helper/scripts/focusElement.js +1 -1
- package/lib/helper/scripts/highlightElement.js +1 -1
- package/lib/helper/scripts/isElementClickable.js +1 -1
- package/lib/helper/testcafe/testControllerHolder.js +1 -1
- package/lib/helper/testcafe/testcafe-utils.js +7 -6
- package/lib/helper.js +3 -1
- package/lib/history.js +5 -6
- package/lib/hooks.js +6 -6
- package/lib/html.js +7 -7
- package/lib/index.js +41 -25
- package/lib/interfaces/bdd.js +64 -47
- package/lib/interfaces/featureConfig.js +19 -19
- package/lib/interfaces/gherkin.js +118 -124
- package/lib/interfaces/scenarioConfig.js +29 -29
- package/lib/listener/artifacts.js +9 -9
- package/lib/listener/config.js +24 -24
- package/lib/listener/exit.js +12 -12
- package/lib/listener/helpers.js +42 -42
- package/lib/listener/mocha.js +11 -11
- package/lib/listener/retry.js +30 -32
- package/lib/listener/steps.js +53 -50
- package/lib/listener/timeout.js +54 -54
- package/lib/locator.js +10 -6
- package/lib/mochaFactory.js +15 -18
- package/lib/output.js +10 -6
- package/lib/parser.js +12 -15
- package/lib/pause.js +33 -40
- package/lib/plugin/allure.js +15 -15
- package/lib/plugin/autoDelay.js +37 -29
- package/lib/plugin/autoLogin.js +65 -70
- package/lib/plugin/commentStep.js +18 -18
- package/lib/plugin/coverage.js +67 -115
- package/lib/plugin/customLocator.js +20 -21
- package/lib/plugin/debugErrors.js +24 -24
- package/lib/plugin/eachElement.js +38 -38
- package/lib/plugin/fakerTransform.js +6 -6
- package/lib/plugin/heal.js +108 -67
- package/lib/plugin/pauseOnFail.js +11 -11
- package/lib/plugin/retryFailedStep.js +39 -32
- package/lib/plugin/retryTo.js +40 -46
- package/lib/plugin/screenshotOnFail.js +87 -109
- package/lib/plugin/selenoid.js +118 -131
- package/lib/plugin/standardActingHelpers.js +8 -2
- package/lib/plugin/stepByStepReport.js +91 -110
- package/lib/plugin/stepTimeout.js +23 -24
- package/lib/plugin/subtitles.js +35 -34
- package/lib/plugin/tryTo.js +30 -40
- package/lib/plugin/wdio.js +75 -78
- package/lib/recorder.js +17 -14
- package/lib/rerun.js +10 -11
- package/lib/scenario.js +23 -25
- package/lib/secret.js +2 -4
- package/lib/session.js +10 -10
- package/lib/step.js +9 -12
- package/lib/store.js +3 -2
- package/lib/transform.js +1 -1
- package/lib/translation.js +8 -7
- package/lib/ui.js +14 -12
- package/lib/utils.js +72 -70
- package/lib/within.js +10 -10
- package/lib/workerStorage.js +25 -27
- package/lib/workers.js +32 -29
- package/package.json +53 -51
- package/translations/de-DE.js +1 -1
- package/translations/fr-FR.js +1 -1
- package/translations/index.js +13 -9
- package/translations/it-IT.js +1 -1
- package/translations/ja-JP.js +1 -1
- package/translations/pl-PL.js +1 -1
- package/translations/pt-BR.js +1 -1
- package/translations/ru-RU.js +1 -1
- package/translations/zh-CN.js +1 -1
- package/translations/zh-TW.js +1 -1
- package/typings/index.d.ts +65 -415
- package/typings/promiseBasedTypes.d.ts +32 -0
- package/typings/types.d.ts +32 -0
package/lib/helper/REST.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { beautify } = require('../utils')
|
|
1
|
+
import { default as axios } from 'axios';
|
|
2
|
+
import Helper from '@codeceptjs/helper';
|
|
3
|
+
import Secret from '../secret.js';
|
|
4
|
+
import { beautify } from '../utils.js';
|
|
5
|
+
import { output } from '../output.js';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* ## Configuration
|
|
@@ -11,16 +10,14 @@ const { beautify } = require('../utils')
|
|
|
11
10
|
* @typedef RESTConfig
|
|
12
11
|
* @type {object}
|
|
13
12
|
* @prop {string} [endpoint] - API base URL
|
|
14
|
-
* @prop {boolean} [prettyPrintJson=false] - pretty print json for response/request on console logs
|
|
15
|
-
* @prop {
|
|
16
|
-
* @prop {
|
|
17
|
-
* @prop {
|
|
18
|
-
* @prop {
|
|
19
|
-
* @prop {function} [onRequest] - an async function which can update request object.
|
|
20
|
-
* @prop {function} [onResponse] - an async function which can update response object.
|
|
13
|
+
* @prop {boolean} [prettyPrintJson=false] - pretty print json for response/request on console logs
|
|
14
|
+
* @prop {number} [timeout=1000] - timeout for requests in milliseconds. 10000ms by default
|
|
15
|
+
* @prop {object} [defaultHeaders] - a list of default headers
|
|
16
|
+
* @prop {function} [onRequest] - a async function which can update request object.
|
|
17
|
+
* @prop {function} [onResponse] - a async function which can update response object.
|
|
21
18
|
* @prop {number} [maxUploadFileSize] - set the max content file size in MB when performing api calls.
|
|
22
19
|
*/
|
|
23
|
-
const config = {}
|
|
20
|
+
const config = {};
|
|
24
21
|
|
|
25
22
|
/**
|
|
26
23
|
* REST helper allows to send additional requests to the REST API during acceptance tests.
|
|
@@ -44,41 +41,6 @@ const config = {}
|
|
|
44
41
|
*}
|
|
45
42
|
* ```
|
|
46
43
|
*
|
|
47
|
-
* With httpAgent
|
|
48
|
-
*
|
|
49
|
-
* ```js
|
|
50
|
-
* {
|
|
51
|
-
* helpers: {
|
|
52
|
-
* REST: {
|
|
53
|
-
* endpoint: 'http://site.com/api',
|
|
54
|
-
* prettyPrintJson: true,
|
|
55
|
-
* httpAgent: {
|
|
56
|
-
* key: fs.readFileSync(__dirname + '/path/to/keyfile.key'),
|
|
57
|
-
* cert: fs.readFileSync(__dirname + '/path/to/certfile.cert'),
|
|
58
|
-
* rejectUnauthorized: false,
|
|
59
|
-
* keepAlive: true
|
|
60
|
-
* }
|
|
61
|
-
* }
|
|
62
|
-
* }
|
|
63
|
-
* }
|
|
64
|
-
* ```
|
|
65
|
-
*
|
|
66
|
-
* ```js
|
|
67
|
-
* {
|
|
68
|
-
* helpers: {
|
|
69
|
-
* REST: {
|
|
70
|
-
* endpoint: 'http://site.com/api',
|
|
71
|
-
* prettyPrintJson: true,
|
|
72
|
-
* httpAgent: {
|
|
73
|
-
* ca: fs.readFileSync(__dirname + '/path/to/ca.pem'),
|
|
74
|
-
* rejectUnauthorized: false,
|
|
75
|
-
* keepAlive: true
|
|
76
|
-
* }
|
|
77
|
-
* }
|
|
78
|
-
* }
|
|
79
|
-
* }
|
|
80
|
-
* ```
|
|
81
|
-
*
|
|
82
44
|
* ## Access From Helpers
|
|
83
45
|
*
|
|
84
46
|
* Send REST requests by accessing `_executeRequest` method:
|
|
@@ -94,7 +56,7 @@ const config = {}
|
|
|
94
56
|
*/
|
|
95
57
|
class REST extends Helper {
|
|
96
58
|
constructor(config) {
|
|
97
|
-
super(config)
|
|
59
|
+
super(config);
|
|
98
60
|
this.options = {
|
|
99
61
|
timeout: 10000,
|
|
100
62
|
defaultHeaders: {},
|
|
@@ -102,55 +64,39 @@ class REST extends Helper {
|
|
|
102
64
|
prettyPrintJson: false,
|
|
103
65
|
onRequest: null,
|
|
104
66
|
onResponse: null,
|
|
105
|
-
}
|
|
67
|
+
};
|
|
106
68
|
|
|
107
69
|
if (this.options.maxContentLength) {
|
|
108
|
-
const maxContentLength = this.options.maxUploadFileSize * 1024 * 1024
|
|
109
|
-
this.options.maxContentLength = maxContentLength
|
|
110
|
-
this.options.maxBodyLength = maxContentLength
|
|
70
|
+
const maxContentLength = this.options.maxUploadFileSize * 1024 * 1024;
|
|
71
|
+
this.options.maxContentLength = maxContentLength;
|
|
72
|
+
this.options.maxBodyLength = maxContentLength;
|
|
111
73
|
}
|
|
112
74
|
|
|
113
75
|
// override defaults with config
|
|
114
|
-
this._setConfig(config)
|
|
115
|
-
|
|
116
|
-
this.headers = { ...this.options.defaultHeaders }
|
|
117
|
-
|
|
118
|
-
// Create an agent with SSL certificate
|
|
119
|
-
if (this.options.httpAgent) {
|
|
120
|
-
// if one of those keys is there, all good to go
|
|
121
|
-
if (this.options.httpAgent.ca || this.options.httpAgent.key || this.options.httpAgent.cert) {
|
|
122
|
-
this.httpsAgent = new Agent(this.options.httpAgent)
|
|
123
|
-
} else {
|
|
124
|
-
// otherwise, throws an error of httpAgent config
|
|
125
|
-
throw Error('Please recheck your httpAgent config!')
|
|
126
|
-
}
|
|
127
|
-
}
|
|
76
|
+
this._setConfig(config);
|
|
128
77
|
|
|
129
|
-
this.
|
|
78
|
+
this.headers = { ...this.options.defaultHeaders };
|
|
79
|
+
this.axios = axios.create();
|
|
130
80
|
// @ts-ignore
|
|
131
|
-
this.axios.defaults.headers = this.options.defaultHeaders
|
|
81
|
+
this.axios.defaults.headers = this.options.defaultHeaders;
|
|
132
82
|
}
|
|
133
83
|
|
|
134
84
|
static _config() {
|
|
135
85
|
return [
|
|
136
|
-
{
|
|
137
|
-
|
|
138
|
-
message: 'Endpoint of API you are going to test',
|
|
139
|
-
default: 'http://localhost:3000/api',
|
|
140
|
-
},
|
|
141
|
-
]
|
|
86
|
+
{ name: 'endpoint', message: 'Endpoint of API you are going to test', default: 'http://localhost:3000/api' },
|
|
87
|
+
];
|
|
142
88
|
}
|
|
143
89
|
|
|
144
90
|
static _checkRequirements() {
|
|
145
91
|
try {
|
|
146
|
-
require('axios')
|
|
92
|
+
require('axios');
|
|
147
93
|
} catch (e) {
|
|
148
|
-
return ['axios']
|
|
94
|
+
return ['axios'];
|
|
149
95
|
}
|
|
150
96
|
}
|
|
151
97
|
|
|
152
98
|
_before() {
|
|
153
|
-
this.headers = { ...this.options.defaultHeaders }
|
|
99
|
+
this.headers = { ...this.options.defaultHeaders };
|
|
154
100
|
}
|
|
155
101
|
|
|
156
102
|
/**
|
|
@@ -159,7 +105,7 @@ class REST extends Helper {
|
|
|
159
105
|
* @param {object} headers headers list
|
|
160
106
|
*/
|
|
161
107
|
haveRequestHeaders(headers) {
|
|
162
|
-
this.headers = { ...this.headers, ...headers }
|
|
108
|
+
this.headers = { ...this.headers, ...headers };
|
|
163
109
|
}
|
|
164
110
|
|
|
165
111
|
/**
|
|
@@ -173,7 +119,7 @@ class REST extends Helper {
|
|
|
173
119
|
* @param {string | CodeceptJS.Secret} accessToken Bearer access token
|
|
174
120
|
*/
|
|
175
121
|
amBearerAuthenticated(accessToken) {
|
|
176
|
-
this.haveRequestHeaders({ Authorization: `Bearer ${accessToken}` })
|
|
122
|
+
this.haveRequestHeaders({ Authorization: `Bearer ${accessToken}` });
|
|
177
123
|
}
|
|
178
124
|
|
|
179
125
|
/**
|
|
@@ -185,65 +131,54 @@ class REST extends Helper {
|
|
|
185
131
|
*/
|
|
186
132
|
async _executeRequest(request) {
|
|
187
133
|
// Add custom headers. They can be set by amBearerAuthenticated() or haveRequestHeaders()
|
|
188
|
-
request.headers = { ...this.headers, ...request.headers }
|
|
134
|
+
request.headers = { ...this.headers, ...request.headers };
|
|
189
135
|
|
|
190
|
-
const _debugRequest = { ...request }
|
|
191
|
-
this.axios.defaults.timeout = request.timeout || this.options.timeout
|
|
136
|
+
const _debugRequest = { ...request };
|
|
137
|
+
this.axios.defaults.timeout = request.timeout || this.options.timeout;
|
|
192
138
|
|
|
193
139
|
if (this.headers && this.headers.auth) {
|
|
194
|
-
request.auth = this.headers.auth
|
|
140
|
+
request.auth = this.headers.auth;
|
|
195
141
|
}
|
|
196
142
|
|
|
197
143
|
if (typeof request.data === 'object') {
|
|
198
|
-
const returnedValue = {}
|
|
144
|
+
const returnedValue = {};
|
|
199
145
|
for (const [key, value] of Object.entries(request.data)) {
|
|
200
|
-
returnedValue[key] = value
|
|
201
|
-
if (value instanceof Secret) returnedValue[key] = value.getMasked()
|
|
146
|
+
returnedValue[key] = value;
|
|
147
|
+
if (value instanceof Secret) returnedValue[key] = value.getMasked();
|
|
202
148
|
}
|
|
203
|
-
_debugRequest.data = returnedValue
|
|
149
|
+
_debugRequest.data = returnedValue;
|
|
204
150
|
}
|
|
205
151
|
|
|
206
152
|
if (request.data instanceof Secret) {
|
|
207
|
-
_debugRequest.data = '*****'
|
|
208
|
-
request.data =
|
|
209
|
-
typeof request.data === 'object' && !(request.data instanceof Secret)
|
|
210
|
-
? { ...request.data.toString() }
|
|
211
|
-
: request.data.toString()
|
|
153
|
+
_debugRequest.data = '*****';
|
|
154
|
+
request.data = (typeof request.data === 'object' && !(request.data instanceof Secret)) ? { ...request.data.toString() } : request.data.toString();
|
|
212
155
|
}
|
|
213
156
|
|
|
214
|
-
if (typeof request.data === 'string') {
|
|
157
|
+
if ((typeof request.data) === 'string') {
|
|
215
158
|
if (!request.headers || !request.headers['Content-Type']) {
|
|
216
|
-
request.headers = { ...request.headers, ...{ 'Content-Type': 'application/x-www-form-urlencoded' } }
|
|
159
|
+
request.headers = { ...request.headers, ...{ 'Content-Type': 'application/x-www-form-urlencoded' } };
|
|
217
160
|
}
|
|
218
161
|
}
|
|
219
162
|
|
|
220
163
|
if (this.config.onRequest) {
|
|
221
|
-
await this.config.onRequest(request)
|
|
164
|
+
await this.config.onRequest(request);
|
|
222
165
|
}
|
|
223
166
|
|
|
224
|
-
this.options.prettyPrintJson
|
|
225
|
-
? this.debugSection('Request', beautify(JSON.stringify(_debugRequest)))
|
|
226
|
-
: this.debugSection('Request', JSON.stringify(_debugRequest))
|
|
167
|
+
this.options.prettyPrintJson ? output.debugSection('Request', beautify(JSON.stringify(_debugRequest))) : output.debugSection('Request', JSON.stringify(_debugRequest));
|
|
227
168
|
|
|
228
|
-
|
|
229
|
-
this.debugSection('CURL Request', curlize(request))
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
let response
|
|
169
|
+
let response;
|
|
233
170
|
try {
|
|
234
|
-
response = await this.axios(request)
|
|
171
|
+
response = await this.axios(request);
|
|
235
172
|
} catch (err) {
|
|
236
|
-
if (!err.response) throw err
|
|
237
|
-
|
|
238
|
-
response = err.response
|
|
173
|
+
if (!err.response) throw err;
|
|
174
|
+
output.debugSection('Response', `Response error. Status code: ${err.response.status}`);
|
|
175
|
+
response = err.response;
|
|
239
176
|
}
|
|
240
177
|
if (this.config.onResponse) {
|
|
241
|
-
await this.config.onResponse(response)
|
|
178
|
+
await this.config.onResponse(response);
|
|
242
179
|
}
|
|
243
|
-
this.options.prettyPrintJson
|
|
244
|
-
|
|
245
|
-
: this.debugSection('Response', JSON.stringify(response.data))
|
|
246
|
-
return response
|
|
180
|
+
this.options.prettyPrintJson ? output.debugSection('Response', beautify(JSON.stringify(response.data))) : output.debugSection('Response', JSON.stringify(response.data));
|
|
181
|
+
return response;
|
|
247
182
|
}
|
|
248
183
|
|
|
249
184
|
/**
|
|
@@ -252,7 +187,7 @@ class REST extends Helper {
|
|
|
252
187
|
* @param {*} url
|
|
253
188
|
*/
|
|
254
189
|
_url(url) {
|
|
255
|
-
return /^\w+\:\/\//.test(url) ? url : this.options.endpoint + url
|
|
190
|
+
return /^\w+\:\/\//.test(url) ? url : this.options.endpoint + url;
|
|
256
191
|
}
|
|
257
192
|
|
|
258
193
|
/**
|
|
@@ -265,7 +200,7 @@ class REST extends Helper {
|
|
|
265
200
|
* @param {number} newTimeout - timeout in milliseconds
|
|
266
201
|
*/
|
|
267
202
|
setRequestTimeout(newTimeout) {
|
|
268
|
-
this.options.timeout = newTimeout
|
|
203
|
+
this.options.timeout = newTimeout;
|
|
269
204
|
}
|
|
270
205
|
|
|
271
206
|
/**
|
|
@@ -284,8 +219,8 @@ class REST extends Helper {
|
|
|
284
219
|
const request = {
|
|
285
220
|
baseURL: this._url(url),
|
|
286
221
|
headers,
|
|
287
|
-
}
|
|
288
|
-
return this._executeRequest(request)
|
|
222
|
+
};
|
|
223
|
+
return this._executeRequest(request);
|
|
289
224
|
}
|
|
290
225
|
|
|
291
226
|
/**
|
|
@@ -311,14 +246,14 @@ class REST extends Helper {
|
|
|
311
246
|
method: 'POST',
|
|
312
247
|
data: payload,
|
|
313
248
|
headers,
|
|
314
|
-
}
|
|
249
|
+
};
|
|
315
250
|
|
|
316
251
|
if (this.options.maxContentLength) {
|
|
317
|
-
request.maxContentLength = this.options.maxContentLength
|
|
318
|
-
request.maxBodyLength = this.options.maxContentLength
|
|
252
|
+
request.maxContentLength = this.options.maxContentLength;
|
|
253
|
+
request.maxBodyLength = this.options.maxContentLength;
|
|
319
254
|
}
|
|
320
255
|
|
|
321
|
-
return this._executeRequest(request)
|
|
256
|
+
return this._executeRequest(request);
|
|
322
257
|
}
|
|
323
258
|
|
|
324
259
|
/**
|
|
@@ -344,14 +279,14 @@ class REST extends Helper {
|
|
|
344
279
|
method: 'PATCH',
|
|
345
280
|
data: payload,
|
|
346
281
|
headers,
|
|
347
|
-
}
|
|
282
|
+
};
|
|
348
283
|
|
|
349
284
|
if (this.options.maxContentLength) {
|
|
350
|
-
request.maxContentLength = this.options.maxContentLength
|
|
351
|
-
request.maxBodyLength = this.options.maxBodyLength
|
|
285
|
+
request.maxContentLength = this.options.maxContentLength;
|
|
286
|
+
request.maxBodyLength = this.options.maxBodyLength;
|
|
352
287
|
}
|
|
353
288
|
|
|
354
|
-
return this._executeRequest(request)
|
|
289
|
+
return this._executeRequest(request);
|
|
355
290
|
}
|
|
356
291
|
|
|
357
292
|
/**
|
|
@@ -377,14 +312,14 @@ class REST extends Helper {
|
|
|
377
312
|
method: 'PUT',
|
|
378
313
|
data: payload,
|
|
379
314
|
headers,
|
|
380
|
-
}
|
|
315
|
+
};
|
|
381
316
|
|
|
382
317
|
if (this.options.maxContentLength) {
|
|
383
|
-
request.maxContentLength = this.options.maxContentLength
|
|
384
|
-
request.maxBodyLength = this.options.maxBodyLength
|
|
318
|
+
request.maxContentLength = this.options.maxContentLength;
|
|
319
|
+
request.maxBodyLength = this.options.maxBodyLength;
|
|
385
320
|
}
|
|
386
321
|
|
|
387
|
-
return this._executeRequest(request)
|
|
322
|
+
return this._executeRequest(request);
|
|
388
323
|
}
|
|
389
324
|
|
|
390
325
|
/**
|
|
@@ -404,35 +339,9 @@ class REST extends Helper {
|
|
|
404
339
|
baseURL: this._url(url),
|
|
405
340
|
method: 'DELETE',
|
|
406
341
|
headers,
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
return this._executeRequest(request)
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
module.exports = REST
|
|
414
|
-
|
|
415
|
-
function curlize(request) {
|
|
416
|
-
if (request.data?.constructor.name.toLowerCase() === 'formdata')
|
|
417
|
-
return 'cURL is not printed as the request body is not a JSON'
|
|
418
|
-
let curl =
|
|
419
|
-
`curl --location --request ${request.method ? request.method.toUpperCase() : 'GET'} ${request.baseURL} `.replace(
|
|
420
|
-
"'",
|
|
421
|
-
'',
|
|
422
|
-
)
|
|
423
|
-
|
|
424
|
-
if (request.headers) {
|
|
425
|
-
Object.entries(request.headers).forEach(([key, value]) => {
|
|
426
|
-
curl += `-H "${key}: ${value}" `
|
|
427
|
-
})
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
if (!curl.toLowerCase().includes('content-type: application/json')) {
|
|
431
|
-
curl += '-H "Content-Type: application/json" '
|
|
432
|
-
}
|
|
342
|
+
};
|
|
433
343
|
|
|
434
|
-
|
|
435
|
-
curl += `-d '${JSON.stringify(request.data)}'`
|
|
344
|
+
return this._executeRequest(request);
|
|
436
345
|
}
|
|
437
|
-
return curl
|
|
438
346
|
}
|
|
347
|
+
export default REST;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import ExpectHelper from './ExpectHelper.js'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* SoftAssertHelper is a utility class for performing soft assertions.
|
|
@@ -378,4 +378,4 @@ class SoftAssertHelper extends ExpectHelper {
|
|
|
378
378
|
this.softAssert(() => this.expectMatchesPattern(actualValue, expectedPattern, customErrorMsg), customErrorMsg)
|
|
379
379
|
}
|
|
380
380
|
}
|
|
381
|
-
|
|
381
|
+
export default SoftAssertHelper
|