codeceptjs 3.6.2-beta.1 → 3.6.2-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.
@@ -1,5 +1,6 @@
1
1
  const axios = require('axios').default;
2
2
  const Helper = require('@codeceptjs/helper');
3
+ const { Agent } = require('https');
3
4
  const Secret = require('../secret');
4
5
 
5
6
  const { beautify } = require('../utils');
@@ -13,6 +14,7 @@ const { beautify } = require('../utils');
13
14
  * @prop {boolean} [prettyPrintJson=false] - pretty print json for response/request on console logs
14
15
  * @prop {number} [timeout=1000] - timeout for requests in milliseconds. 10000ms by default
15
16
  * @prop {object} [defaultHeaders] - a list of default headers
17
+ * @prop {object} [httpAgent] - create an agent with SSL certificate
16
18
  * @prop {function} [onRequest] - a async function which can update request object.
17
19
  * @prop {function} [onResponse] - a async function which can update response object.
18
20
  * @prop {number} [maxUploadFileSize] - set the max content file size in MB when performing api calls.
@@ -40,6 +42,24 @@ const config = {};
40
42
  * }
41
43
  *}
42
44
  * ```
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
+ * ```
43
63
  *
44
64
  * ## Access From Helpers
45
65
  *
@@ -76,7 +96,14 @@ class REST extends Helper {
76
96
  this._setConfig(config);
77
97
 
78
98
  this.headers = { ...this.options.defaultHeaders };
79
- this.axios = axios.create();
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
107
  // @ts-ignore
81
108
  this.axios.defaults.headers = this.options.defaultHeaders;
82
109
  }
package/lib/locator.js CHANGED
@@ -299,6 +299,15 @@ class Locator {
299
299
  return new Locator({ xpath });
300
300
  }
301
301
 
302
+ /**
303
+ * @param {String} text
304
+ * @returns {Locator}
305
+ */
306
+ withClassAttr(text) {
307
+ const xpath = sprintf('%s[%s]', this.toXPath(), `contains(@class, '${text}')`);
308
+ return new Locator({ xpath });
309
+ }
310
+
302
311
  /**
303
312
  * @param {string} output
304
313
  * @returns {Locator}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codeceptjs",
3
- "version": "3.6.2-beta.1",
3
+ "version": "3.6.2-beta.2",
4
4
  "description": "Supercharged End 2 End Testing Framework for NodeJS",
5
5
  "keywords": [
6
6
  "acceptance",
@@ -135,7 +135,7 @@
135
135
  "chai-subset": "1.6.0",
136
136
  "contributor-faces": "1.1.0",
137
137
  "documentation": "12.3.0",
138
- "electron": "28.2.1",
138
+ "electron": "30.0.1",
139
139
  "eslint": "8.56.0",
140
140
  "eslint-config-airbnb-base": "15.0.0",
141
141
  "eslint-plugin-import": "2.29.1",
@@ -1154,7 +1154,6 @@ declare namespace CodeceptJS {
1154
1154
  *
1155
1155
  * ## Methods
1156
1156
  */
1157
- // @ts-ignore
1158
1157
  class ExpectHelper {
1159
1158
  expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): Promise<any>;
1160
1159
  expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): Promise<any>;
@@ -1781,7 +1780,6 @@ declare namespace CodeceptJS {
1781
1780
  * @property [host = "0.0.0.0"] - Mock server host
1782
1781
  * @property [httpsOpts] - key & cert values are the paths to .key and .crt files
1783
1782
  */
1784
- // @ts-ignore
1785
1783
  type MockServerConfig = {
1786
1784
  port?: number;
1787
1785
  host?: string;
@@ -1906,7 +1904,6 @@ declare namespace CodeceptJS {
1906
1904
  *
1907
1905
  * ## Methods
1908
1906
  */
1909
- // @ts-ignore
1910
1907
  class MockServer {
1911
1908
  /**
1912
1909
  * Start the mock server
@@ -8031,6 +8028,24 @@ declare namespace CodeceptJS {
8031
8028
  * }
8032
8029
  * }
8033
8030
  * ```
8031
+ * With httpAgent
8032
+ *
8033
+ * ```js
8034
+ * {
8035
+ * helpers: {
8036
+ * REST: {
8037
+ * endpoint: 'http://site.com/api',
8038
+ * prettyPrintJson: true,
8039
+ * httpAgent: {
8040
+ * key: fs.readFileSync(__dirname + '/path/to/keyfile.key'),
8041
+ * cert: fs.readFileSync(__dirname + '/path/to/certfile.cert'),
8042
+ * rejectUnauthorized: false,
8043
+ * keepAlive: true
8044
+ * }
8045
+ * }
8046
+ * }
8047
+ * }
8048
+ * ```
8034
8049
  *
8035
8050
  * ## Access From Helpers
8036
8051
  *
@@ -1178,7 +1178,6 @@ declare namespace CodeceptJS {
1178
1178
  *
1179
1179
  * ## Methods
1180
1180
  */
1181
- // @ts-ignore
1182
1181
  class ExpectHelper {
1183
1182
  expectEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
1184
1183
  expectNotEqual(actualValue: any, expectedValue: any, customErrorMsg?: any): void;
@@ -1808,7 +1807,6 @@ declare namespace CodeceptJS {
1808
1807
  * @property [host = "0.0.0.0"] - Mock server host
1809
1808
  * @property [httpsOpts] - key & cert values are the paths to .key and .crt files
1810
1809
  */
1811
- // @ts-ignore
1812
1810
  type MockServerConfig = {
1813
1811
  port?: number;
1814
1812
  host?: string;
@@ -1933,7 +1931,6 @@ declare namespace CodeceptJS {
1933
1931
  *
1934
1932
  * ## Methods
1935
1933
  */
1936
- // @ts-ignore
1937
1934
  class MockServer {
1938
1935
  /**
1939
1936
  * Start the mock server
@@ -8528,6 +8525,7 @@ declare namespace CodeceptJS {
8528
8525
  * @property [prettyPrintJson = false] - pretty print json for response/request on console logs
8529
8526
  * @property [timeout = 1000] - timeout for requests in milliseconds. 10000ms by default
8530
8527
  * @property [defaultHeaders] - a list of default headers
8528
+ * @property [httpAgent] - create an agent with SSL certificate
8531
8529
  * @property [onRequest] - a async function which can update request object.
8532
8530
  * @property [onResponse] - a async function which can update response object.
8533
8531
  * @property [maxUploadFileSize] - set the max content file size in MB when performing api calls.
@@ -8537,6 +8535,7 @@ declare namespace CodeceptJS {
8537
8535
  prettyPrintJson?: boolean;
8538
8536
  timeout?: number;
8539
8537
  defaultHeaders?: any;
8538
+ httpAgent?: any;
8540
8539
  onRequest?: (...params: any[]) => any;
8541
8540
  onResponse?: (...params: any[]) => any;
8542
8541
  maxUploadFileSize?: number;
@@ -8562,6 +8561,24 @@ declare namespace CodeceptJS {
8562
8561
  * }
8563
8562
  * }
8564
8563
  * ```
8564
+ * With httpAgent
8565
+ *
8566
+ * ```js
8567
+ * {
8568
+ * helpers: {
8569
+ * REST: {
8570
+ * endpoint: 'http://site.com/api',
8571
+ * prettyPrintJson: true,
8572
+ * httpAgent: {
8573
+ * key: fs.readFileSync(__dirname + '/path/to/keyfile.key'),
8574
+ * cert: fs.readFileSync(__dirname + '/path/to/certfile.cert'),
8575
+ * rejectUnauthorized: false,
8576
+ * keepAlive: true
8577
+ * }
8578
+ * }
8579
+ * }
8580
+ * }
8581
+ * ```
8565
8582
  *
8566
8583
  * ## Access From Helpers
8567
8584
  *
@@ -12158,6 +12175,7 @@ declare namespace CodeceptJS {
12158
12175
  withAttr(attributes: {
12159
12176
  [key: string]: string;
12160
12177
  }): Locator;
12178
+ withClassAttr(text: string): Locator;
12161
12179
  as(output: string): Locator;
12162
12180
  inside(locator: CodeceptJS.LocatorOrString): Locator;
12163
12181
  after(locator: CodeceptJS.LocatorOrString): Locator;