codeceptjs 4.0.0-beta.4 → 4.0.0-beta.6.esm-aria

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 (188) hide show
  1. package/README.md +89 -119
  2. package/bin/codecept.js +53 -54
  3. package/docs/webapi/clearCookie.mustache +1 -1
  4. package/lib/actor.js +70 -102
  5. package/lib/ai.js +131 -121
  6. package/lib/assert/empty.js +11 -12
  7. package/lib/assert/equal.js +16 -21
  8. package/lib/assert/error.js +2 -2
  9. package/lib/assert/include.js +11 -15
  10. package/lib/assert/throws.js +3 -5
  11. package/lib/assert/truth.js +10 -7
  12. package/lib/assert.js +18 -18
  13. package/lib/codecept.js +112 -101
  14. package/lib/colorUtils.js +48 -50
  15. package/lib/command/check.js +206 -0
  16. package/lib/command/configMigrate.js +13 -14
  17. package/lib/command/definitions.js +24 -36
  18. package/lib/command/dryRun.js +16 -16
  19. package/lib/command/generate.js +38 -39
  20. package/lib/command/gherkin/init.js +36 -38
  21. package/lib/command/gherkin/snippets.js +76 -74
  22. package/lib/command/gherkin/steps.js +21 -18
  23. package/lib/command/info.js +49 -15
  24. package/lib/command/init.js +41 -37
  25. package/lib/command/interactive.js +22 -13
  26. package/lib/command/list.js +11 -10
  27. package/lib/command/run-multiple/chunk.js +50 -47
  28. package/lib/command/run-multiple/collection.js +5 -5
  29. package/lib/command/run-multiple/run.js +3 -3
  30. package/lib/command/run-multiple.js +27 -47
  31. package/lib/command/run-rerun.js +6 -7
  32. package/lib/command/run-workers.js +15 -66
  33. package/lib/command/run.js +8 -8
  34. package/lib/command/utils.js +22 -21
  35. package/lib/command/workers/runTests.js +131 -241
  36. package/lib/config.js +111 -49
  37. package/lib/container.js +589 -244
  38. package/lib/data/context.js +16 -18
  39. package/lib/data/dataScenarioConfig.js +9 -9
  40. package/lib/data/dataTableArgument.js +7 -7
  41. package/lib/data/table.js +6 -12
  42. package/lib/effects.js +307 -0
  43. package/lib/els.js +160 -0
  44. package/lib/event.js +24 -19
  45. package/lib/globals.js +141 -0
  46. package/lib/heal.js +89 -81
  47. package/lib/helper/AI.js +3 -2
  48. package/lib/helper/ApiDataFactory.js +19 -19
  49. package/lib/helper/Appium.js +47 -51
  50. package/lib/helper/FileSystem.js +35 -15
  51. package/lib/helper/GraphQL.js +1 -1
  52. package/lib/helper/GraphQLDataFactory.js +4 -4
  53. package/lib/helper/JSONResponse.js +72 -45
  54. package/lib/helper/Mochawesome.js +14 -11
  55. package/lib/helper/Playwright.js +832 -434
  56. package/lib/helper/Puppeteer.js +393 -292
  57. package/lib/helper/REST.js +32 -27
  58. package/lib/helper/WebDriver.js +320 -219
  59. package/lib/helper/errors/ConnectionRefused.js +6 -6
  60. package/lib/helper/errors/ElementAssertion.js +11 -16
  61. package/lib/helper/errors/ElementNotFound.js +5 -9
  62. package/lib/helper/errors/RemoteBrowserConnectionRefused.js +5 -5
  63. package/lib/helper/extras/Console.js +11 -11
  64. package/lib/helper/extras/PlaywrightLocator.js +110 -0
  65. package/lib/helper/extras/PlaywrightPropEngine.js +18 -18
  66. package/lib/helper/extras/PlaywrightRestartOpts.js +23 -23
  67. package/lib/helper/extras/Popup.js +22 -22
  68. package/lib/helper/extras/React.js +29 -30
  69. package/lib/helper/network/actions.js +33 -48
  70. package/lib/helper/network/utils.js +76 -83
  71. package/lib/helper/scripts/blurElement.js +6 -6
  72. package/lib/helper/scripts/focusElement.js +6 -6
  73. package/lib/helper/scripts/highlightElement.js +9 -9
  74. package/lib/helper/scripts/isElementClickable.js +34 -34
  75. package/lib/helper.js +2 -1
  76. package/lib/history.js +23 -20
  77. package/lib/hooks.js +10 -10
  78. package/lib/html.js +90 -100
  79. package/lib/index.js +48 -21
  80. package/lib/listener/config.js +8 -9
  81. package/lib/listener/emptyRun.js +54 -0
  82. package/lib/listener/exit.js +10 -12
  83. package/lib/listener/{retry.js → globalRetry.js} +10 -10
  84. package/lib/listener/globalTimeout.js +166 -0
  85. package/lib/listener/helpers.js +43 -24
  86. package/lib/listener/mocha.js +4 -5
  87. package/lib/listener/result.js +11 -0
  88. package/lib/listener/steps.js +26 -23
  89. package/lib/listener/store.js +20 -0
  90. package/lib/locator.js +213 -192
  91. package/lib/mocha/asyncWrapper.js +264 -0
  92. package/lib/mocha/bdd.js +167 -0
  93. package/lib/mocha/cli.js +341 -0
  94. package/lib/mocha/factory.js +160 -0
  95. package/lib/{interfaces → mocha}/featureConfig.js +33 -13
  96. package/lib/{interfaces → mocha}/gherkin.js +75 -45
  97. package/lib/mocha/hooks.js +121 -0
  98. package/lib/mocha/index.js +21 -0
  99. package/lib/mocha/inject.js +46 -0
  100. package/lib/{interfaces → mocha}/scenarioConfig.js +32 -8
  101. package/lib/mocha/suite.js +89 -0
  102. package/lib/mocha/test.js +178 -0
  103. package/lib/mocha/types.d.ts +42 -0
  104. package/lib/mocha/ui.js +229 -0
  105. package/lib/output.js +86 -64
  106. package/lib/parser.js +44 -44
  107. package/lib/pause.js +160 -139
  108. package/lib/plugin/analyze.js +403 -0
  109. package/lib/plugin/{autoLogin.js → auth.js} +137 -43
  110. package/lib/plugin/autoDelay.js +19 -15
  111. package/lib/plugin/coverage.js +22 -27
  112. package/lib/plugin/customLocator.js +5 -5
  113. package/lib/plugin/customReporter.js +53 -0
  114. package/lib/plugin/heal.js +49 -17
  115. package/lib/plugin/pageInfo.js +140 -0
  116. package/lib/plugin/pauseOnFail.js +4 -3
  117. package/lib/plugin/retryFailedStep.js +60 -19
  118. package/lib/plugin/screenshotOnFail.js +80 -83
  119. package/lib/plugin/stepByStepReport.js +70 -31
  120. package/lib/plugin/stepTimeout.js +7 -13
  121. package/lib/plugin/subtitles.js +10 -9
  122. package/lib/recorder.js +167 -126
  123. package/lib/rerun.js +94 -50
  124. package/lib/result.js +161 -0
  125. package/lib/secret.js +18 -17
  126. package/lib/session.js +95 -89
  127. package/lib/step/base.js +239 -0
  128. package/lib/step/comment.js +10 -0
  129. package/lib/step/config.js +50 -0
  130. package/lib/step/func.js +46 -0
  131. package/lib/step/helper.js +50 -0
  132. package/lib/step/meta.js +99 -0
  133. package/lib/step/record.js +74 -0
  134. package/lib/step/retry.js +11 -0
  135. package/lib/step/section.js +55 -0
  136. package/lib/step.js +18 -332
  137. package/lib/steps.js +54 -0
  138. package/lib/store.js +37 -5
  139. package/lib/template/heal.js +2 -11
  140. package/lib/timeout.js +60 -0
  141. package/lib/transform.js +8 -8
  142. package/lib/translation.js +32 -18
  143. package/lib/utils.js +354 -250
  144. package/lib/workerStorage.js +16 -16
  145. package/lib/workers.js +366 -282
  146. package/package.json +107 -95
  147. package/translations/de-DE.js +5 -4
  148. package/translations/fr-FR.js +5 -4
  149. package/translations/index.js +23 -9
  150. package/translations/it-IT.js +5 -4
  151. package/translations/ja-JP.js +5 -4
  152. package/translations/nl-NL.js +76 -0
  153. package/translations/pl-PL.js +5 -4
  154. package/translations/pt-BR.js +5 -4
  155. package/translations/ru-RU.js +5 -4
  156. package/translations/utils.js +18 -0
  157. package/translations/zh-CN.js +5 -4
  158. package/translations/zh-TW.js +5 -4
  159. package/typings/index.d.ts +177 -186
  160. package/typings/promiseBasedTypes.d.ts +3573 -5941
  161. package/typings/types.d.ts +4042 -6370
  162. package/lib/cli.js +0 -256
  163. package/lib/helper/ExpectHelper.js +0 -391
  164. package/lib/helper/Nightmare.js +0 -1504
  165. package/lib/helper/Protractor.js +0 -1863
  166. package/lib/helper/SoftExpectHelper.js +0 -381
  167. package/lib/helper/TestCafe.js +0 -1414
  168. package/lib/helper/clientscripts/nightmare.js +0 -213
  169. package/lib/helper/extras/PlaywrightReactVueLocator.js +0 -43
  170. package/lib/helper/testcafe/testControllerHolder.js +0 -42
  171. package/lib/helper/testcafe/testcafe-utils.js +0 -62
  172. package/lib/interfaces/bdd.js +0 -81
  173. package/lib/listener/artifacts.js +0 -19
  174. package/lib/listener/timeout.js +0 -109
  175. package/lib/mochaFactory.js +0 -113
  176. package/lib/plugin/allure.js +0 -15
  177. package/lib/plugin/commentStep.js +0 -136
  178. package/lib/plugin/debugErrors.js +0 -67
  179. package/lib/plugin/eachElement.js +0 -127
  180. package/lib/plugin/fakerTransform.js +0 -49
  181. package/lib/plugin/retryTo.js +0 -127
  182. package/lib/plugin/selenoid.js +0 -384
  183. package/lib/plugin/standardActingHelpers.js +0 -3
  184. package/lib/plugin/tryTo.js +0 -115
  185. package/lib/plugin/wdio.js +0 -249
  186. package/lib/scenario.js +0 -224
  187. package/lib/ui.js +0 -236
  188. package/lib/within.js +0 -70
package/lib/output.js CHANGED
@@ -1,6 +1,6 @@
1
- const colors = require('chalk');
2
- const figures = require('figures');
3
- const { maskSensitiveData } = require('invisi-data')
1
+ import colors from 'chalk'
2
+ import figures from 'figures'
3
+ import { maskSensitiveData } from 'invisi-data'
4
4
 
5
5
  const styles = {
6
6
  error: colors.bgRed.white.bold,
@@ -10,17 +10,18 @@ const styles = {
10
10
  debug: colors.cyan,
11
11
  log: colors.grey,
12
12
  bold: colors.bold,
13
- };
13
+ section: colors.white.dim.bold,
14
+ }
14
15
 
15
- let outputLevel = 0;
16
- let outputProcess = '';
17
- let newline = true;
16
+ let outputLevel = 0
17
+ let outputProcess = ''
18
+ let newline = true
18
19
 
19
20
  /**
20
21
  * @alias output
21
22
  * @namespace
22
23
  */
23
- module.exports = {
24
+ const output = {
24
25
  colors,
25
26
  styles,
26
27
  print,
@@ -28,7 +29,7 @@ module.exports = {
28
29
  stepShift: 0,
29
30
 
30
31
  standWithUkraine() {
31
- return `#${colors.bold.yellow('StandWith')}${colors.bold.cyan('Ukraine')}`;
32
+ return `#${colors.bold.yellow('StandWith')}${colors.bold.cyan('Ukraine')}`
32
33
  },
33
34
 
34
35
  /**
@@ -37,8 +38,8 @@ module.exports = {
37
38
  * @returns {number}
38
39
  */
39
40
  level(level) {
40
- if (level !== undefined) outputLevel = level;
41
- return outputLevel;
41
+ if (level !== undefined) outputLevel = level
42
+ return outputLevel
42
43
  },
43
44
 
44
45
  /**
@@ -48,9 +49,9 @@ module.exports = {
48
49
  * @returns {string}
49
50
  */
50
51
  process(process) {
51
- if (process === null) return outputProcess = '';
52
- if (process) outputProcess = String(process).length === 1 ? `[0${process}]` : `[${process}]`;
53
- return outputProcess;
52
+ if (process === null) return (outputProcess = '')
53
+ if (process) outputProcess = String(process).length === 1 ? `[0${process}]` : `[${process}]`
54
+ return outputProcess
54
55
  },
55
56
 
56
57
  /**
@@ -60,7 +61,7 @@ module.exports = {
60
61
  debug(msg) {
61
62
  const _msg = isMaskedData() ? maskSensitiveData(msg) : msg
62
63
  if (outputLevel >= 2) {
63
- print(' '.repeat(this.stepShift), styles.debug(`${figures.pointerSmall} ${_msg}`));
64
+ print(' '.repeat(output.stepShift), styles.debug(`${figures.pointerSmall} ${_msg}`))
64
65
  }
65
66
  },
66
67
 
@@ -71,7 +72,7 @@ module.exports = {
71
72
  log(msg) {
72
73
  const _msg = isMaskedData() ? maskSensitiveData(msg) : msg
73
74
  if (outputLevel >= 3) {
74
- print(' '.repeat(this.stepShift), styles.log(truncate(` ${_msg}`, this.spaceShift)));
75
+ print(' '.repeat(output.stepShift), styles.log(truncate(` ${_msg}`, output.stepShift)))
75
76
  }
76
77
  },
77
78
 
@@ -80,7 +81,7 @@ module.exports = {
80
81
  * @param {string} msg
81
82
  */
82
83
  error(msg) {
83
- print(styles.error(msg));
84
+ print(styles.error(msg))
84
85
  },
85
86
 
86
87
  /**
@@ -88,7 +89,7 @@ module.exports = {
88
89
  * @param {string} msg
89
90
  */
90
91
  success(msg) {
91
- print(styles.success(msg));
92
+ print(styles.success(msg))
92
93
  },
93
94
 
94
95
  /**
@@ -97,7 +98,7 @@ module.exports = {
97
98
  * @param {string} msg
98
99
  */
99
100
  plugin(pluginName, msg = '') {
100
- this.debug(`<${pluginName}> ${msg}`);
101
+ output.debug(`<${pluginName}> ${msg}`)
101
102
  },
102
103
 
103
104
  /**
@@ -105,26 +106,26 @@ module.exports = {
105
106
  * @param {CodeceptJS.Step} step
106
107
  */
107
108
  step(step) {
108
- if (outputLevel === 0) return;
109
- if (!step) return;
109
+ if (outputLevel === 0) return
110
+ if (!step) return
110
111
  // Avoid to print non-gherkin steps, when gherkin is running for --steps mode
111
112
  if (outputLevel === 1) {
112
113
  if (typeof step === 'object' && step.hasBDDAncestor()) {
113
- return;
114
+ return
114
115
  }
115
116
  }
116
117
 
117
- let stepLine = step.toString();
118
+ let stepLine = step.toCliStyled ? step.toCliStyled() : step.toString()
118
119
  if (step.metaStep && outputLevel >= 1) {
119
120
  // this.stepShift += 2;
120
- stepLine = colors.green(truncate(stepLine, this.spaceShift));
121
+ stepLine = colors.dim(truncate(stepLine, output.stepShift))
121
122
  }
122
123
  if (step.comment) {
123
- stepLine += colors.grey(step.comment.split('\n').join('\n' + ' '.repeat(4)));
124
+ stepLine += colors.grey(step.comment.split('\n').join('\n' + ' '.repeat(4)))
124
125
  }
125
126
 
126
127
  const _stepLine = isMaskedData() ? maskSensitiveData(stepLine) : stepLine
127
- print(' '.repeat(this.stepShift), truncate(_stepLine, this.spaceShift));
128
+ print(' '.repeat(output.stepShift), truncate(_stepLine, output.stepShift))
128
129
  },
129
130
 
130
131
  /** @namespace */
@@ -132,10 +133,11 @@ module.exports = {
132
133
  /**
133
134
  * @param {Mocha.Suite} suite
134
135
  */
135
- started: (suite) => {
136
- if (!suite.title) return;
137
- print(`${colors.bold(suite.title)} --`);
138
- if (suite.comment) print(suite.comment);
136
+ started: suite => {
137
+ if (!suite.title) return
138
+ print(`${colors.bold(suite.title)} --`)
139
+ if (suite.file && outputLevel >= 1) print(colors.underline.grey(suite.file))
140
+ if (suite.comment) print(suite.comment)
139
141
  },
140
142
  },
141
143
 
@@ -145,25 +147,25 @@ module.exports = {
145
147
  * @param {Mocha.Test} test
146
148
  */
147
149
  started(test) {
148
- print(` ${colors.magenta.bold(test.title)}`);
150
+ print(` ${colors.magenta.bold(test.title)}`)
149
151
  },
150
152
  /**
151
153
  * @param {Mocha.Test} test
152
154
  */
153
155
  passed(test) {
154
- print(` ${colors.green.bold(figures.tick)} ${test.title} ${colors.grey(`in ${test.duration}ms`)}`);
156
+ print(` ${colors.green.bold(figures.tick)} ${test.title} ${colors.grey(`in ${test.duration}ms`)}`)
155
157
  },
156
158
  /**
157
159
  * @param {Mocha.Test} test
158
160
  */
159
161
  failed(test) {
160
- print(` ${colors.red.bold(figures.cross)} ${test.title} ${colors.grey(`in ${test.duration}ms`)}`);
162
+ print(` ${colors.red.bold(figures.cross)} ${test.title} ${colors.grey(`in ${test.duration}ms`)}`)
161
163
  },
162
164
  /**
163
165
  * @param {Mocha.Test} test
164
166
  */
165
167
  skipped(test) {
166
- print(` ${colors.yellow.bold('S')} ${test.title}`);
168
+ print(` ${colors.yellow.bold('S')} ${test.title}`)
167
169
  },
168
170
  },
169
171
 
@@ -173,21 +175,39 @@ module.exports = {
173
175
  * @param {Mocha.Test} test
174
176
  */
175
177
 
176
- started(test) {},
178
+ started(test) {
179
+ if (outputLevel < 1) return
180
+ print(` ${colors.dim.bold('Scenario()')}`)
181
+ },
177
182
 
178
183
  /**
179
184
  * @param {Mocha.Test} test
180
185
  */
181
186
  passed(test) {
182
- print(` ${colors.green.bold(`${figures.tick} OK`)} ${colors.grey(`in ${test.duration}ms`)}`);
183
- print();
187
+ print(` ${colors.green.bold(`${figures.tick} OK`)} ${colors.grey(`in ${test.duration}ms`)}`)
188
+ print()
184
189
  },
185
190
  /**
186
191
  * @param {Mocha.Test} test
187
192
  */
188
193
  failed(test) {
189
- print(` ${colors.red.bold(`${figures.cross} FAILED`)} ${colors.grey(`in ${test.duration}ms`)}`);
190
- print();
194
+ print(` ${colors.red.bold(`${figures.cross} FAILED`)} ${colors.grey(`in ${test.duration}ms`)}`)
195
+ print()
196
+ },
197
+ },
198
+
199
+ hook: {
200
+ started(hook) {
201
+ if (outputLevel < 1) return
202
+ print(` ${colors.dim.bold(hook.toCode())}`)
203
+ },
204
+ passed(hook) {
205
+ if (outputLevel < 1) return
206
+ print()
207
+ },
208
+ failed(hook) {
209
+ if (outputLevel < 1) return
210
+ print(` ${colors.red.bold(hook.toCode())}`)
191
211
  },
192
212
  },
193
213
 
@@ -199,9 +219,9 @@ module.exports = {
199
219
  */
200
220
  say(message, color = 'cyan') {
201
221
  if (colors[color] === undefined) {
202
- color = 'cyan';
222
+ color = 'cyan'
203
223
  }
204
- if (outputLevel >= 1) print(` ${colors[color].bold(message)}`);
224
+ if (outputLevel >= 1) print(` ${colors[color].bold(message)}`)
205
225
  },
206
226
 
207
227
  /**
@@ -211,54 +231,56 @@ module.exports = {
211
231
  * @param {number|string} duration
212
232
  */
213
233
  result(passed, failed, skipped, duration, failedHooks = 0) {
214
- let style = colors.bgGreen;
215
- let msg = ` ${passed || 0} passed`;
216
- let status = style.bold(' OK ');
234
+ let style = colors.bgGreen
235
+ let msg = ` ${passed || 0} passed`
236
+ let status = style.bold(' OK ')
217
237
  if (failed) {
218
- style = style.bgRed;
219
- status = style.bold(' FAIL ');
220
- msg += `, ${failed} failed`;
238
+ style = style.bgRed
239
+ status = style.bold(' FAIL ')
240
+ msg += `, ${failed} failed`
221
241
  }
222
242
 
223
243
  if (failedHooks > 0) {
224
- style = style.bgRed;
225
- status = style.bold(' FAIL ');
226
- msg += `, ${failedHooks} failedHooks`;
244
+ style = style.bgRed
245
+ status = style.bold(' FAIL ')
246
+ msg += `, ${failedHooks} failedHooks`
227
247
  }
228
- status += style.grey(' |');
248
+ status += style.grey(' |')
229
249
 
230
250
  if (skipped) {
231
- if (!failed) style = style.bgYellow;
232
- msg += `, ${skipped} skipped`;
251
+ if (!failed) style = style.bgYellow
252
+ msg += `, ${skipped} skipped`
233
253
  }
234
- msg += ' ';
235
- print(status + style(msg) + colors.grey(` // ${duration}`));
254
+ msg += ' '
255
+ print(status + style(msg) + colors.grey(` // ${duration}`))
236
256
  },
237
- };
257
+ }
238
258
 
239
259
  function print(...msg) {
240
260
  if (outputProcess) {
241
- msg.unshift(outputProcess);
261
+ msg.unshift(outputProcess)
242
262
  }
243
263
  if (!newline) {
244
- console.log();
245
- newline = true;
264
+ console.log()
265
+ newline = true
246
266
  }
247
267
 
248
- console.log.apply(this, msg);
268
+ console.log.apply(this, msg)
249
269
  }
250
270
 
251
271
  function truncate(msg, gap = 0) {
252
272
  if (msg.indexOf('\n') > 0 || outputLevel >= 3) {
253
- return msg; // don't cut multi line steps or on verbose log level
273
+ return msg // don't cut multi line steps or on verbose log level
254
274
  }
255
- const width = (process.stdout.columns || 200) - gap - 4;
275
+ const width = (process.stdout.columns || 200) - gap - 4
256
276
  if (msg.length > width) {
257
- msg = msg.substr(0, width - 1) + figures.ellipsis;
277
+ msg = msg.substr(0, width - 1) + figures.ellipsis
258
278
  }
259
- return msg;
279
+ return msg
260
280
  }
261
281
 
262
282
  function isMaskedData() {
263
283
  return global.maskSensitiveData === true || false
264
284
  }
285
+
286
+ export default output
package/lib/parser.js CHANGED
@@ -1,74 +1,74 @@
1
- function _interopDefault(ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex.default : ex; }
2
- const acorn = require('acorn');
3
- const parser = _interopDefault(require('parse-function'))({ parse: acorn.parse, ecmaVersion: 11, plugins: ['objectRestSpread'] });
4
- const { error } = require('./output');
1
+ function _interopDefault(ex) {
2
+ return ex && typeof ex === 'object' && 'default' in ex ? ex.default : ex
3
+ }
4
+ import * as acorn from 'acorn'
5
+ import parseFunctionModule from 'parse-function'
6
+ const parseFunction = _interopDefault(parseFunctionModule)
7
+ const parser = parseFunction({ parse: acorn.parse, ecmaVersion: 11, plugins: ['objectRestSpread'] })
8
+ import output from './output.js'
5
9
 
6
- parser.use(destructuredArgs);
10
+ parser.use(destructuredArgs)
7
11
 
8
- module.exports.getParamsToString = function (fn) {
9
- const newFn = fn.toString().replace(/^async/, 'async function');
10
- return getParams(newFn).join(', ');
11
- };
12
+ export const getParamsToString = function (fn) {
13
+ const newFn = fn.toString().replace(/^async/, 'async function')
14
+ return getParams(newFn).join(', ')
15
+ }
12
16
 
13
17
  function getParams(fn) {
14
- if (fn.isSinonProxy) return [];
18
+ if (fn.isSinonProxy) return []
15
19
  try {
16
- const reflected = parser.parse(fn);
20
+ const reflected = parser.parse(fn)
17
21
  if (reflected.args.length > 1 || reflected.args[0] === 'I') {
18
- error('Error: old CodeceptJS v2 format detected. Upgrade your project to the new format -> https://bit.ly/codecept3Up');
22
+ output.error('Error: old CodeceptJS v2 format detected. Upgrade your project to the new format -> https://bit.ly/codecept3Up')
19
23
  }
20
- if (reflected.destructuredArgs.length > 0) reflected.args = [...reflected.destructuredArgs];
21
- const params = reflected.args.map((p) => {
22
- const def = reflected.defaults[p];
24
+ if (reflected.destructuredArgs.length > 0) reflected.args = [...reflected.destructuredArgs]
25
+ const params = reflected.args.map(p => {
26
+ const def = reflected.defaults[p]
23
27
  if (def) {
24
- return `${p}=${def}`;
28
+ return `${p}=${def}`
25
29
  }
26
- return p;
27
- });
28
- return params;
30
+ return p
31
+ })
32
+ return params
29
33
  } catch (err) {
30
- console.log(`Error in ${fn.toString()}`);
31
- error(err);
34
+ console.log(`Error in ${fn.toString()}`)
35
+ output.error(err)
32
36
  }
33
37
  }
34
38
 
35
- module.exports.getParams = getParams;
39
+ export { getParams }
36
40
 
37
41
  function destructuredArgs() {
38
42
  return (node, result) => {
39
- result.destructuredArgs = result.destructuredArgs || [];
43
+ result.destructuredArgs = result.destructuredArgs || []
40
44
 
41
45
  if (node.type === 'ObjectExpression' && node.properties.length > 0) {
42
- node.properties.forEach((prop) => {
46
+ node.properties.forEach(prop => {
43
47
  if (prop.value && prop.value.params.length > 0) {
44
- result.destructuredArgs = parseDestructuredArgs(prop.value);
48
+ result.destructuredArgs = parseDestructuredArgs(prop.value)
45
49
  }
46
- });
50
+ })
47
51
 
48
- return result;
52
+ return result
49
53
  }
50
54
 
51
- if (!Array.isArray(node.params)) return result;
52
- result.destructuredArgs = parseDestructuredArgs(node);
55
+ if (!Array.isArray(node.params)) return result
56
+ result.destructuredArgs = parseDestructuredArgs(node)
53
57
 
54
- return result;
55
- };
58
+ return result
59
+ }
56
60
  }
57
61
 
58
62
  function parseDestructuredArgs(node) {
59
- const destructuredArgs = [];
60
- node.params.forEach((param) => {
61
- if (
62
- param.type === 'ObjectPattern'
63
- && param.properties
64
- && param.properties.length > 0
65
- ) {
66
- param.properties.forEach((prop) => {
67
- const { name } = prop.value;
68
- destructuredArgs.push(name);
69
- });
63
+ const destructuredArgs = []
64
+ node.params.forEach(param => {
65
+ if (param.type === 'ObjectPattern' && param.properties && param.properties.length > 0) {
66
+ param.properties.forEach(prop => {
67
+ const { name } = prop.value
68
+ destructuredArgs.push(name)
69
+ })
70
70
  }
71
- });
71
+ })
72
72
 
73
- return destructuredArgs;
73
+ return destructuredArgs
74
74
  }