codeceptjs 3.6.4 → 3.6.5-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.
Files changed (88) hide show
  1. package/bin/codecept.js +84 -63
  2. package/lib/assert/empty.js +19 -19
  3. package/lib/assert/equal.js +32 -30
  4. package/lib/assert/error.js +14 -14
  5. package/lib/assert/include.js +42 -42
  6. package/lib/assert/throws.js +13 -11
  7. package/lib/assert/truth.js +17 -18
  8. package/lib/command/configMigrate.js +57 -52
  9. package/lib/command/definitions.js +88 -88
  10. package/lib/command/dryRun.js +65 -63
  11. package/lib/command/generate.js +191 -181
  12. package/lib/command/info.js +39 -37
  13. package/lib/command/init.js +289 -286
  14. package/lib/command/interactive.js +32 -32
  15. package/lib/command/list.js +26 -26
  16. package/lib/command/run-multiple.js +113 -93
  17. package/lib/command/run-rerun.js +22 -22
  18. package/lib/command/run-workers.js +63 -63
  19. package/lib/command/run.js +24 -26
  20. package/lib/command/utils.js +64 -63
  21. package/lib/data/context.js +60 -60
  22. package/lib/data/dataScenarioConfig.js +47 -47
  23. package/lib/data/dataTableArgument.js +29 -29
  24. package/lib/data/table.js +26 -20
  25. package/lib/helper/AI.js +67 -65
  26. package/lib/helper/ApiDataFactory.js +72 -69
  27. package/lib/helper/Appium.js +409 -379
  28. package/lib/helper/ExpectHelper.js +214 -248
  29. package/lib/helper/FileSystem.js +77 -78
  30. package/lib/helper/GraphQL.js +44 -43
  31. package/lib/helper/GraphQLDataFactory.js +49 -50
  32. package/lib/helper/JSONResponse.js +64 -62
  33. package/lib/helper/Mochawesome.js +28 -28
  34. package/lib/helper/MockServer.js +12 -12
  35. package/lib/helper/Nightmare.js +664 -572
  36. package/lib/helper/Playwright.js +1320 -1211
  37. package/lib/helper/Protractor.js +663 -629
  38. package/lib/helper/Puppeteer.js +1232 -1124
  39. package/lib/helper/REST.js +87 -72
  40. package/lib/helper/TestCafe.js +490 -491
  41. package/lib/helper/WebDriver.js +1294 -1156
  42. package/lib/interfaces/bdd.js +38 -51
  43. package/lib/interfaces/featureConfig.js +19 -19
  44. package/lib/interfaces/gherkin.js +122 -111
  45. package/lib/interfaces/scenarioConfig.js +29 -29
  46. package/lib/listener/artifacts.js +9 -9
  47. package/lib/listener/config.js +24 -23
  48. package/lib/listener/exit.js +12 -12
  49. package/lib/listener/helpers.js +42 -42
  50. package/lib/listener/mocha.js +11 -11
  51. package/lib/listener/retry.js +32 -30
  52. package/lib/listener/steps.js +50 -51
  53. package/lib/listener/timeout.js +53 -53
  54. package/lib/plugin/allure.js +14 -14
  55. package/lib/plugin/autoDelay.js +29 -36
  56. package/lib/plugin/autoLogin.js +70 -66
  57. package/lib/plugin/commentStep.js +18 -18
  58. package/lib/plugin/coverage.js +92 -77
  59. package/lib/plugin/customLocator.js +20 -19
  60. package/lib/plugin/debugErrors.js +24 -24
  61. package/lib/plugin/eachElement.js +37 -37
  62. package/lib/plugin/fakerTransform.js +6 -6
  63. package/lib/plugin/heal.js +66 -63
  64. package/lib/plugin/pauseOnFail.js +10 -10
  65. package/lib/plugin/retryFailedStep.js +31 -38
  66. package/lib/plugin/retryTo.js +28 -28
  67. package/lib/plugin/screenshotOnFail.js +107 -86
  68. package/lib/plugin/selenoid.js +131 -117
  69. package/lib/plugin/standardActingHelpers.js +2 -8
  70. package/lib/plugin/stepByStepReport.js +102 -92
  71. package/lib/plugin/stepTimeout.js +23 -22
  72. package/lib/plugin/subtitles.js +34 -34
  73. package/lib/plugin/tryTo.js +39 -29
  74. package/lib/plugin/wdio.js +77 -72
  75. package/lib/template/heal.js +11 -14
  76. package/package.json +4 -2
  77. package/translations/de-DE.js +1 -1
  78. package/translations/fr-FR.js +1 -1
  79. package/translations/index.js +9 -9
  80. package/translations/it-IT.js +1 -1
  81. package/translations/ja-JP.js +1 -1
  82. package/translations/pl-PL.js +1 -1
  83. package/translations/pt-BR.js +1 -1
  84. package/translations/ru-RU.js +1 -1
  85. package/translations/zh-CN.js +1 -1
  86. package/translations/zh-TW.js +1 -1
  87. package/typings/promiseBasedTypes.d.ts +238 -0
  88. package/typings/types.d.ts +32 -0
@@ -1,13 +1,13 @@
1
- const Helper = require('@codeceptjs/helper');
1
+ const Helper = require('@codeceptjs/helper')
2
2
 
3
- let expect;
3
+ let expect
4
4
 
5
- import('chai').then(chai => {
6
- expect = chai.expect;
7
- chai.use(require('chai-deep-match'));
8
- });
5
+ import('chai').then((chai) => {
6
+ expect = chai.expect
7
+ chai.use(require('chai-deep-match'))
8
+ })
9
9
 
10
- const joi = require('joi');
10
+ const joi = require('joi')
11
11
 
12
12
  /**
13
13
  * This helper allows performing assertions on JSON responses paired with following helpers:
@@ -67,33 +67,35 @@ const joi = require('joi');
67
67
  */
68
68
  class JSONResponse extends Helper {
69
69
  constructor(config = {}) {
70
- super(config);
70
+ super(config)
71
71
  this.options = {
72
72
  requestHelper: 'REST',
73
- };
74
- this.options = { ...this.options, ...config };
73
+ }
74
+ this.options = { ...this.options, ...config }
75
75
  }
76
76
 
77
77
  _beforeSuite() {
78
- this.response = null;
78
+ this.response = null
79
79
  if (!this.helpers[this.options.requestHelper]) {
80
- throw new Error(`Error setting JSONResponse, helper ${this.options.requestHelper} is not enabled in config, helpers: ${Object.keys(this.helpers)}`);
80
+ throw new Error(
81
+ `Error setting JSONResponse, helper ${this.options.requestHelper} is not enabled in config, helpers: ${Object.keys(this.helpers)}`,
82
+ )
81
83
  }
82
84
  // connect to REST helper
83
85
  this.helpers[this.options.requestHelper].config.onResponse = (response) => {
84
- this.response = response;
85
- };
86
+ this.response = response
87
+ }
86
88
  }
87
89
 
88
90
  _before() {
89
- this.response = null;
91
+ this.response = null
90
92
  }
91
93
 
92
94
  static _checkRequirements() {
93
95
  try {
94
- require('joi');
96
+ require('joi')
95
97
  } catch (e) {
96
- return ['joi'];
98
+ return ['joi']
97
99
  }
98
100
  }
99
101
 
@@ -107,8 +109,8 @@ class JSONResponse extends Helper {
107
109
  * @param {number} code
108
110
  */
109
111
  seeResponseCodeIs(code) {
110
- this._checkResponseReady();
111
- expect(this.response.status).to.eql(code, 'Response code is not the same as expected');
112
+ this._checkResponseReady()
113
+ expect(this.response.status).to.eql(code, 'Response code is not the same as expected')
112
114
  }
113
115
 
114
116
  /**
@@ -121,35 +123,35 @@ class JSONResponse extends Helper {
121
123
  * @param {number} code
122
124
  */
123
125
  dontSeeResponseCodeIs(code) {
124
- this._checkResponseReady();
125
- expect(this.response.status).not.to.eql(code);
126
+ this._checkResponseReady()
127
+ expect(this.response.status).not.to.eql(code)
126
128
  }
127
129
 
128
130
  /**
129
131
  * Checks that the response code is 4xx
130
132
  */
131
133
  seeResponseCodeIsClientError() {
132
- this._checkResponseReady();
133
- expect(this.response.status).to.be.gte(400);
134
- expect(this.response.status).to.be.lt(500);
134
+ this._checkResponseReady()
135
+ expect(this.response.status).to.be.gte(400)
136
+ expect(this.response.status).to.be.lt(500)
135
137
  }
136
138
 
137
139
  /**
138
140
  * Checks that the response code is 3xx
139
141
  */
140
142
  seeResponseCodeIsRedirection() {
141
- this._checkResponseReady();
142
- expect(this.response.status).to.be.gte(300);
143
- expect(this.response.status).to.be.lt(400);
143
+ this._checkResponseReady()
144
+ expect(this.response.status).to.be.gte(300)
145
+ expect(this.response.status).to.be.lt(400)
144
146
  }
145
147
 
146
148
  /**
147
149
  * Checks that the response code is 5xx
148
150
  */
149
151
  seeResponseCodeIsServerError() {
150
- this._checkResponseReady();
151
- expect(this.response.status).to.be.gte(500);
152
- expect(this.response.status).to.be.lt(600);
152
+ this._checkResponseReady()
153
+ expect(this.response.status).to.be.gte(500)
154
+ expect(this.response.status).to.be.lt(600)
153
155
  }
154
156
 
155
157
  /**
@@ -161,9 +163,9 @@ class JSONResponse extends Helper {
161
163
  * ```
162
164
  */
163
165
  seeResponseCodeIsSuccessful() {
164
- this._checkResponseReady();
165
- expect(this.response.status).to.be.gte(200);
166
- expect(this.response.status).to.be.lt(300);
166
+ this._checkResponseReady()
167
+ expect(this.response.status).to.be.gte(200)
168
+ expect(this.response.status).to.be.lt(300)
167
169
  }
168
170
 
169
171
  /**
@@ -184,19 +186,19 @@ class JSONResponse extends Helper {
184
186
  * @param {object} json
185
187
  */
186
188
  seeResponseContainsJson(json = {}) {
187
- this._checkResponseReady();
189
+ this._checkResponseReady()
188
190
  if (Array.isArray(this.response.data)) {
189
- let fails = 0;
191
+ let fails = 0
190
192
  for (const el of this.response.data) {
191
193
  try {
192
- expect(el).to.deep.match(json);
194
+ expect(el).to.deep.match(json)
193
195
  } catch (err) {
194
- fails++;
196
+ fails++
195
197
  }
196
198
  }
197
- expect(fails < this.response.data.length, `No elements in array matched ${JSON.stringify(json)}`).to.be.true;
199
+ expect(fails < this.response.data.length, `No elements in array matched ${JSON.stringify(json)}`).to.be.true
198
200
  } else {
199
- expect(this.response.data).to.deep.match(json);
201
+ expect(this.response.data).to.deep.match(json)
200
202
  }
201
203
  }
202
204
 
@@ -218,11 +220,11 @@ class JSONResponse extends Helper {
218
220
  * @param {object} json
219
221
  */
220
222
  dontSeeResponseContainsJson(json = {}) {
221
- this._checkResponseReady();
223
+ this._checkResponseReady()
222
224
  if (Array.isArray(this.response.data)) {
223
- this.response.data.forEach(data => expect(data).not.to.deep.match(json));
225
+ this.response.data.forEach((data) => expect(data).not.to.deep.match(json))
224
226
  } else {
225
- expect(this.response.data).not.to.deep.match(json);
227
+ expect(this.response.data).not.to.deep.match(json)
226
228
  }
227
229
  }
228
230
 
@@ -246,11 +248,11 @@ class JSONResponse extends Helper {
246
248
  * @param {array} keys
247
249
  */
248
250
  seeResponseContainsKeys(keys = []) {
249
- this._checkResponseReady();
251
+ this._checkResponseReady()
250
252
  if (Array.isArray(this.response.data)) {
251
- this.response.data.forEach(data => expect(data).to.include.keys(keys));
253
+ this.response.data.forEach((data) => expect(data).to.include.keys(keys))
252
254
  } else {
253
- expect(this.response.data).to.include.keys(keys);
255
+ expect(this.response.data).to.include.keys(keys)
254
256
  }
255
257
  }
256
258
 
@@ -268,10 +270,10 @@ class JSONResponse extends Helper {
268
270
  * @param {function} fn
269
271
  */
270
272
  seeResponseValidByCallback(fn) {
271
- this._checkResponseReady();
272
- fn({ ...this.response, expect });
273
- const body = fn.toString();
274
- fn.toString = () => `${body.split('\n')[1]}...`;
273
+ this._checkResponseReady()
274
+ fn({ ...this.response, expect })
275
+ const body = fn.toString()
276
+ fn.toString = () => `${body.split('\n')[1]}...`
275
277
  }
276
278
 
277
279
  /**
@@ -285,8 +287,8 @@ class JSONResponse extends Helper {
285
287
  * @param {object} resp
286
288
  */
287
289
  seeResponseEquals(resp) {
288
- this._checkResponseReady();
289
- expect(this.response.data).to.deep.equal(resp);
290
+ this._checkResponseReady()
291
+ expect(this.response.data).to.deep.equal(resp)
290
292
  }
291
293
 
292
294
  /**
@@ -317,22 +319,22 @@ class JSONResponse extends Helper {
317
319
  * @param {any} fnOrSchema
318
320
  */
319
321
  seeResponseMatchesJsonSchema(fnOrSchema) {
320
- this._checkResponseReady();
321
- let schema = fnOrSchema;
322
+ this._checkResponseReady()
323
+ let schema = fnOrSchema
322
324
  if (typeof fnOrSchema === 'function') {
323
- schema = fnOrSchema(joi);
324
- const body = fnOrSchema.toString();
325
- fnOrSchema.toString = () => `${body.split('\n')[1]}...`;
325
+ schema = fnOrSchema(joi)
326
+ const body = fnOrSchema.toString()
327
+ fnOrSchema.toString = () => `${body.split('\n')[1]}...`
326
328
  }
327
- if (!schema) throw new Error('Empty Joi schema provided, see https://joi.dev/ for details');
328
- if (!joi.isSchema(schema)) throw new Error('Invalid Joi schema provided, see https://joi.dev/ for details');
329
- schema.toString = () => schema.describe();
330
- joi.assert(this.response.data, schema);
329
+ if (!schema) throw new Error('Empty Joi schema provided, see https://joi.dev/ for details')
330
+ if (!joi.isSchema(schema)) throw new Error('Invalid Joi schema provided, see https://joi.dev/ for details')
331
+ schema.toString = () => schema.describe()
332
+ joi.assert(this.response.data, schema)
331
333
  }
332
334
 
333
335
  _checkResponseReady() {
334
- if (!this.response) throw new Error('Response is not available');
336
+ if (!this.response) throw new Error('Response is not available')
335
337
  }
336
338
  }
337
339
 
338
- module.exports = JSONResponse;
340
+ module.exports = JSONResponse
@@ -1,71 +1,71 @@
1
- let addMochawesomeContext;
2
- let currentTest;
3
- let currentSuite;
1
+ let addMochawesomeContext
2
+ let currentTest
3
+ let currentSuite
4
4
 
5
- const Helper = require('@codeceptjs/helper');
6
- const { clearString } = require('../utils');
5
+ const Helper = require('@codeceptjs/helper')
6
+ const { clearString } = require('../utils')
7
7
 
8
8
  class Mochawesome extends Helper {
9
9
  constructor(config) {
10
- super(config);
10
+ super(config)
11
11
 
12
12
  // set defaults
13
13
  this.options = {
14
14
  uniqueScreenshotNames: false,
15
15
  disableScreenshots: false,
16
- };
16
+ }
17
17
 
18
- addMochawesomeContext = require('mochawesome/addContext');
19
- this._createConfig(config);
18
+ addMochawesomeContext = require('mochawesome/addContext')
19
+ this._createConfig(config)
20
20
  }
21
21
 
22
22
  _createConfig(config) {
23
23
  // override defaults with config
24
- Object.assign(this.options, config);
24
+ Object.assign(this.options, config)
25
25
  }
26
26
 
27
27
  _beforeSuite(suite) {
28
- currentSuite = suite;
29
- currentTest = '';
28
+ currentSuite = suite
29
+ currentTest = ''
30
30
  }
31
31
 
32
32
  _before() {
33
33
  if (currentSuite && currentSuite.ctx) {
34
- currentTest = { test: currentSuite.ctx.currentTest };
34
+ currentTest = { test: currentSuite.ctx.currentTest }
35
35
  }
36
36
  }
37
37
 
38
38
  _test(test) {
39
- currentTest = { test };
39
+ currentTest = { test }
40
40
  }
41
41
 
42
42
  _failed(test) {
43
- if (this.options.disableScreenshots) return;
44
- let fileName;
43
+ if (this.options.disableScreenshots) return
44
+ let fileName
45
45
  // Get proper name if we are fail on hook
46
46
  if (test.ctx.test.type === 'hook') {
47
- currentTest = { test: test.ctx.test };
47
+ currentTest = { test: test.ctx.test }
48
48
  // ignore retries if we are in hook
49
- test._retries = -1;
50
- fileName = clearString(`${test.title}_${currentTest.test.title}`);
49
+ test._retries = -1
50
+ fileName = clearString(`${test.title}_${currentTest.test.title}`)
51
51
  } else {
52
- currentTest = { test };
53
- fileName = clearString(test.title);
52
+ currentTest = { test }
53
+ fileName = clearString(test.title)
54
54
  }
55
55
  if (this.options.uniqueScreenshotNames) {
56
- const uuid = test.uuid || test.ctx.test.uuid;
57
- fileName = `${fileName.substring(0, 10)}_${uuid}`;
56
+ const uuid = test.uuid || test.ctx.test.uuid
57
+ fileName = `${fileName.substring(0, 10)}_${uuid}`
58
58
  }
59
59
  if (test._retries < 1 || test._retries === test.retryNum) {
60
- fileName = `${fileName}.failed.png`;
61
- return addMochawesomeContext(currentTest, fileName);
60
+ fileName = `${fileName}.failed.png`
61
+ return addMochawesomeContext(currentTest, fileName)
62
62
  }
63
63
  }
64
64
 
65
65
  addMochawesomeContext(context) {
66
- if (currentTest === '') currentTest = { test: currentSuite.ctx.test };
67
- return addMochawesomeContext(currentTest, context);
66
+ if (currentTest === '') currentTest = { test: currentSuite.ctx.test }
67
+ return addMochawesomeContext(currentTest, context)
68
68
  }
69
69
  }
70
70
 
71
- module.exports = Mochawesome;
71
+ module.exports = Mochawesome
@@ -1,4 +1,4 @@
1
- const { mock, settings } = require('pactum');
1
+ const { mock, settings } = require('pactum')
2
2
 
3
3
  /**
4
4
  * ## Configuration
@@ -18,7 +18,7 @@ let config = {
18
18
  key: '',
19
19
  cert: '',
20
20
  },
21
- };
21
+ }
22
22
 
23
23
  /**
24
24
  * MockServer
@@ -141,10 +141,10 @@ let config = {
141
141
  */
142
142
  class MockServer {
143
143
  constructor(passedConfig) {
144
- settings.setLogLevel('SILENT');
145
- config = { ...passedConfig };
144
+ settings.setLogLevel('SILENT')
145
+ config = { ...passedConfig }
146
146
  if (global.debugMode) {
147
- settings.setLogLevel('VERBOSE');
147
+ settings.setLogLevel('VERBOSE')
148
148
  }
149
149
  }
150
150
 
@@ -155,10 +155,10 @@ class MockServer {
155
155
  * @returns void
156
156
  */
157
157
  async startMockServer(port) {
158
- const _config = { ...config };
159
- if (port) _config.port = port;
160
- await mock.setDefaults(_config);
161
- await mock.start();
158
+ const _config = { ...config }
159
+ if (port) _config.port = port
160
+ await mock.setDefaults(_config)
161
+ await mock.start()
162
162
  }
163
163
 
164
164
  /**
@@ -168,7 +168,7 @@ class MockServer {
168
168
  *
169
169
  */
170
170
  async stopMockServer() {
171
- await mock.stop();
171
+ await mock.stop()
172
172
  }
173
173
 
174
174
  /**
@@ -214,8 +214,8 @@ class MockServer {
214
214
  *
215
215
  */
216
216
  async addInteractionToMockServer(interaction) {
217
- await mock.addInteraction(interaction);
217
+ await mock.addInteraction(interaction)
218
218
  }
219
219
  }
220
220
 
221
- module.exports = MockServer;
221
+ module.exports = MockServer