codeceptjs 3.6.3 → 3.6.4-beta.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/lib/heal.js +1 -1
- package/lib/helper/REST.js +27 -33
- package/package.json +4 -4
- package/typings/promiseBasedTypes.d.ts +4 -18
- package/typings/types.d.ts +11 -25
package/lib/heal.js
CHANGED
|
@@ -154,7 +154,7 @@ module.exports = heal;
|
|
|
154
154
|
function matchRecipes(recipes, contextName) {
|
|
155
155
|
return Object.entries(recipes)
|
|
156
156
|
.filter(([, recipe]) => !contextName || !recipe.grep || new RegExp(recipe.grep).test(contextName))
|
|
157
|
-
.sort(([, a], [, b]) =>
|
|
157
|
+
.sort(([, a], [, b]) => a.priority - b.priority)
|
|
158
158
|
.map(([name, recipe]) => {
|
|
159
159
|
recipe.name = name;
|
|
160
160
|
return recipe;
|
package/lib/helper/REST.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const axios = require('axios').default;
|
|
2
2
|
const Helper = require('@codeceptjs/helper');
|
|
3
|
-
const { Agent } = require('https');
|
|
4
3
|
const Secret = require('../secret');
|
|
5
4
|
|
|
6
5
|
const { beautify } = require('../utils');
|
|
@@ -11,12 +10,12 @@ 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 {object} [
|
|
18
|
-
* @prop {function} [onRequest] -
|
|
19
|
-
* @prop {function} [onResponse] -
|
|
13
|
+
* @prop {boolean} [prettyPrintJson=false] - pretty print json for response/request on console logs.
|
|
14
|
+
* @prop {boolean} [printCurl=false] - print cURL request on console logs. False by default.
|
|
15
|
+
* @prop {number} [timeout=1000] - timeout for requests in milliseconds. 10000ms by default.
|
|
16
|
+
* @prop {object} [defaultHeaders] - a list of default headers.
|
|
17
|
+
* @prop {function} [onRequest] - an async function which can update request object.
|
|
18
|
+
* @prop {function} [onResponse] - an async function which can update response object.
|
|
20
19
|
* @prop {number} [maxUploadFileSize] - set the max content file size in MB when performing api calls.
|
|
21
20
|
*/
|
|
22
21
|
const config = {};
|
|
@@ -42,24 +41,6 @@ const config = {};
|
|
|
42
41
|
* }
|
|
43
42
|
*}
|
|
44
43
|
* ```
|
|
45
|
-
* With httpAgent
|
|
46
|
-
*
|
|
47
|
-
* ```js
|
|
48
|
-
* {
|
|
49
|
-
* helpers: {
|
|
50
|
-
* REST: {
|
|
51
|
-
* endpoint: 'http://site.com/api',
|
|
52
|
-
* prettyPrintJson: true,
|
|
53
|
-
* httpAgent: {
|
|
54
|
-
* key: fs.readFileSync(__dirname + '/path/to/keyfile.key'),
|
|
55
|
-
* cert: fs.readFileSync(__dirname + '/path/to/certfile.cert'),
|
|
56
|
-
* rejectUnauthorized: false,
|
|
57
|
-
* keepAlive: true
|
|
58
|
-
* }
|
|
59
|
-
* }
|
|
60
|
-
* }
|
|
61
|
-
* }
|
|
62
|
-
* ```
|
|
63
44
|
*
|
|
64
45
|
* ## Access From Helpers
|
|
65
46
|
*
|
|
@@ -96,14 +77,7 @@ class REST extends Helper {
|
|
|
96
77
|
this._setConfig(config);
|
|
97
78
|
|
|
98
79
|
this.headers = { ...this.options.defaultHeaders };
|
|
99
|
-
|
|
100
|
-
// Create an agent with SSL certificate
|
|
101
|
-
if (this.options.httpAgent) {
|
|
102
|
-
if (!this.options.httpAgent.key || !this.options.httpAgent.cert) throw Error('Please recheck your httpAgent config!');
|
|
103
|
-
this.httpsAgent = new Agent(this.options.httpAgent);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
this.axios = this.httpsAgent ? axios.create({ httpsAgent: this.httpsAgent }) : axios.create();
|
|
80
|
+
this.axios = axios.create();
|
|
107
81
|
// @ts-ignore
|
|
108
82
|
this.axios.defaults.headers = this.options.defaultHeaders;
|
|
109
83
|
}
|
|
@@ -192,6 +166,7 @@ class REST extends Helper {
|
|
|
192
166
|
}
|
|
193
167
|
|
|
194
168
|
this.options.prettyPrintJson ? this.debugSection('Request', beautify(JSON.stringify(_debugRequest))) : this.debugSection('Request', JSON.stringify(_debugRequest));
|
|
169
|
+
if (this.options.printCurl) this.debugSection('CURL Request', curlize(request));
|
|
195
170
|
|
|
196
171
|
let response;
|
|
197
172
|
try {
|
|
@@ -372,3 +347,22 @@ class REST extends Helper {
|
|
|
372
347
|
}
|
|
373
348
|
}
|
|
374
349
|
module.exports = REST;
|
|
350
|
+
|
|
351
|
+
function curlize(request) {
|
|
352
|
+
let curl = `curl --location --request ${request.method ? request.method.toUpperCase() : 'GET'} ${request.baseURL} `.replace("'", '');
|
|
353
|
+
|
|
354
|
+
if (request.headers) {
|
|
355
|
+
Object.entries(request.headers).forEach(([key, value]) => {
|
|
356
|
+
curl += `-H "${key}: ${value}" `;
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if (!curl.toLowerCase().includes('content-type: application/json')) {
|
|
361
|
+
curl += '-H "Content-Type: application/json" ';
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (request.data) {
|
|
365
|
+
curl += `-d '${JSON.stringify(request.data)}'`;
|
|
366
|
+
}
|
|
367
|
+
return curl;
|
|
368
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codeceptjs",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.4-beta.2",
|
|
4
4
|
"description": "Supercharged End 2 End Testing Framework for NodeJS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"acceptance",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"glob": "6.0.1",
|
|
99
99
|
"html-minifier-terser": "7.2.0",
|
|
100
100
|
"inquirer": "6.5.2",
|
|
101
|
-
"joi": "17.13.
|
|
101
|
+
"joi": "17.13.1",
|
|
102
102
|
"js-beautify": "1.15.1",
|
|
103
103
|
"lodash.clonedeep": "4.5.0",
|
|
104
104
|
"lodash.merge": "4.6.2",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"@types/node": "20.11.30",
|
|
129
129
|
"@wdio/sauce-service": "8.35.1",
|
|
130
130
|
"@wdio/selenium-standalone-service": "8.3.2",
|
|
131
|
-
"@wdio/utils": "8.
|
|
131
|
+
"@wdio/utils": "8.38.2",
|
|
132
132
|
"@xmldom/xmldom": "0.8.10",
|
|
133
133
|
"apollo-server-express": "2.25.3",
|
|
134
134
|
"chai-as-promised": "7.1.2",
|
|
@@ -179,4 +179,4 @@
|
|
|
179
179
|
"strict": false
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
|
-
}
|
|
182
|
+
}
|
|
@@ -1154,6 +1154,7 @@ declare namespace CodeceptJS {
|
|
|
1154
1154
|
*
|
|
1155
1155
|
* ## Methods
|
|
1156
1156
|
*/
|
|
1157
|
+
// @ts-ignore
|
|
1157
1158
|
class ExpectHelper {
|
|
1158
1159
|
expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): Promise<any>;
|
|
1159
1160
|
expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): Promise<any>;
|
|
@@ -1265,6 +1266,7 @@ declare namespace CodeceptJS {
|
|
|
1265
1266
|
*
|
|
1266
1267
|
* ## Methods
|
|
1267
1268
|
*/
|
|
1269
|
+
// @ts-ignore
|
|
1268
1270
|
class ExpectHelper {
|
|
1269
1271
|
expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): Promise<any>;
|
|
1270
1272
|
expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): Promise<any>;
|
|
@@ -1936,6 +1938,7 @@ declare namespace CodeceptJS {
|
|
|
1936
1938
|
* @property [host = "0.0.0.0"] - Mock server host
|
|
1937
1939
|
* @property [httpsOpts] - key & cert values are the paths to .key and .crt files
|
|
1938
1940
|
*/
|
|
1941
|
+
// @ts-ignore
|
|
1939
1942
|
type MockServerConfig = {
|
|
1940
1943
|
port?: number;
|
|
1941
1944
|
host?: string;
|
|
@@ -2060,6 +2063,7 @@ declare namespace CodeceptJS {
|
|
|
2060
2063
|
*
|
|
2061
2064
|
* ## Methods
|
|
2062
2065
|
*/
|
|
2066
|
+
// @ts-ignore
|
|
2063
2067
|
class MockServer {
|
|
2064
2068
|
/**
|
|
2065
2069
|
* Start the mock server
|
|
@@ -8184,24 +8188,6 @@ declare namespace CodeceptJS {
|
|
|
8184
8188
|
* }
|
|
8185
8189
|
* }
|
|
8186
8190
|
* ```
|
|
8187
|
-
* With httpAgent
|
|
8188
|
-
*
|
|
8189
|
-
* ```js
|
|
8190
|
-
* {
|
|
8191
|
-
* helpers: {
|
|
8192
|
-
* REST: {
|
|
8193
|
-
* endpoint: 'http://site.com/api',
|
|
8194
|
-
* prettyPrintJson: true,
|
|
8195
|
-
* httpAgent: {
|
|
8196
|
-
* key: fs.readFileSync(__dirname + '/path/to/keyfile.key'),
|
|
8197
|
-
* cert: fs.readFileSync(__dirname + '/path/to/certfile.cert'),
|
|
8198
|
-
* rejectUnauthorized: false,
|
|
8199
|
-
* keepAlive: true
|
|
8200
|
-
* }
|
|
8201
|
-
* }
|
|
8202
|
-
* }
|
|
8203
|
-
* }
|
|
8204
|
-
* ```
|
|
8205
8191
|
*
|
|
8206
8192
|
* ## Access From Helpers
|
|
8207
8193
|
*
|
package/typings/types.d.ts
CHANGED
|
@@ -1178,6 +1178,7 @@ declare namespace CodeceptJS {
|
|
|
1178
1178
|
*
|
|
1179
1179
|
* ## Methods
|
|
1180
1180
|
*/
|
|
1181
|
+
// @ts-ignore
|
|
1181
1182
|
class ExpectHelper {
|
|
1182
1183
|
expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1183
1184
|
expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
@@ -1289,6 +1290,7 @@ declare namespace CodeceptJS {
|
|
|
1289
1290
|
*
|
|
1290
1291
|
* ## Methods
|
|
1291
1292
|
*/
|
|
1293
|
+
// @ts-ignore
|
|
1292
1294
|
class ExpectHelper {
|
|
1293
1295
|
expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
1294
1296
|
expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
|
|
@@ -1963,6 +1965,7 @@ declare namespace CodeceptJS {
|
|
|
1963
1965
|
* @property [host = "0.0.0.0"] - Mock server host
|
|
1964
1966
|
* @property [httpsOpts] - key & cert values are the paths to .key and .crt files
|
|
1965
1967
|
*/
|
|
1968
|
+
// @ts-ignore
|
|
1966
1969
|
type MockServerConfig = {
|
|
1967
1970
|
port?: number;
|
|
1968
1971
|
host?: string;
|
|
@@ -2087,6 +2090,7 @@ declare namespace CodeceptJS {
|
|
|
2087
2090
|
*
|
|
2088
2091
|
* ## Methods
|
|
2089
2092
|
*/
|
|
2093
|
+
// @ts-ignore
|
|
2090
2094
|
class MockServer {
|
|
2091
2095
|
/**
|
|
2092
2096
|
* Start the mock server
|
|
@@ -8678,20 +8682,20 @@ declare namespace CodeceptJS {
|
|
|
8678
8682
|
/**
|
|
8679
8683
|
* ## Configuration
|
|
8680
8684
|
* @property [endpoint] - API base URL
|
|
8681
|
-
* @property [prettyPrintJson = false] - pretty print json for response/request on console logs
|
|
8682
|
-
* @property [
|
|
8683
|
-
* @property [
|
|
8684
|
-
* @property [
|
|
8685
|
-
* @property [onRequest] -
|
|
8686
|
-
* @property [onResponse] -
|
|
8685
|
+
* @property [prettyPrintJson = false] - pretty print json for response/request on console logs.
|
|
8686
|
+
* @property [printCurl = false] - print cURL request on console logs. False by default.
|
|
8687
|
+
* @property [timeout = 1000] - timeout for requests in milliseconds. 10000ms by default.
|
|
8688
|
+
* @property [defaultHeaders] - a list of default headers.
|
|
8689
|
+
* @property [onRequest] - an async function which can update request object.
|
|
8690
|
+
* @property [onResponse] - an async function which can update response object.
|
|
8687
8691
|
* @property [maxUploadFileSize] - set the max content file size in MB when performing api calls.
|
|
8688
8692
|
*/
|
|
8689
8693
|
type RESTConfig = {
|
|
8690
8694
|
endpoint?: string;
|
|
8691
8695
|
prettyPrintJson?: boolean;
|
|
8696
|
+
printCurl?: boolean;
|
|
8692
8697
|
timeout?: number;
|
|
8693
8698
|
defaultHeaders?: any;
|
|
8694
|
-
httpAgent?: any;
|
|
8695
8699
|
onRequest?: (...params: any[]) => any;
|
|
8696
8700
|
onResponse?: (...params: any[]) => any;
|
|
8697
8701
|
maxUploadFileSize?: number;
|
|
@@ -8717,24 +8721,6 @@ declare namespace CodeceptJS {
|
|
|
8717
8721
|
* }
|
|
8718
8722
|
* }
|
|
8719
8723
|
* ```
|
|
8720
|
-
* With httpAgent
|
|
8721
|
-
*
|
|
8722
|
-
* ```js
|
|
8723
|
-
* {
|
|
8724
|
-
* helpers: {
|
|
8725
|
-
* REST: {
|
|
8726
|
-
* endpoint: 'http://site.com/api',
|
|
8727
|
-
* prettyPrintJson: true,
|
|
8728
|
-
* httpAgent: {
|
|
8729
|
-
* key: fs.readFileSync(__dirname + '/path/to/keyfile.key'),
|
|
8730
|
-
* cert: fs.readFileSync(__dirname + '/path/to/certfile.cert'),
|
|
8731
|
-
* rejectUnauthorized: false,
|
|
8732
|
-
* keepAlive: true
|
|
8733
|
-
* }
|
|
8734
|
-
* }
|
|
8735
|
-
* }
|
|
8736
|
-
* }
|
|
8737
|
-
* ```
|
|
8738
8724
|
*
|
|
8739
8725
|
* ## Access From Helpers
|
|
8740
8726
|
*
|