codeceptjs 4.0.0-beta.2 → 4.0.0-beta.4

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 (152) hide show
  1. package/README.md +2 -2
  2. package/bin/codecept.js +84 -81
  3. package/lib/actor.js +13 -13
  4. package/lib/ai.js +10 -13
  5. package/lib/assert/empty.js +20 -21
  6. package/lib/assert/equal.js +37 -39
  7. package/lib/assert/error.js +14 -14
  8. package/lib/assert/include.js +46 -47
  9. package/lib/assert/throws.js +13 -11
  10. package/lib/assert/truth.js +19 -22
  11. package/lib/assert.js +4 -2
  12. package/lib/cli.js +56 -49
  13. package/lib/codecept.js +145 -155
  14. package/lib/colorUtils.js +3 -3
  15. package/lib/command/configMigrate.js +58 -52
  16. package/lib/command/definitions.js +88 -89
  17. package/lib/command/dryRun.js +79 -81
  18. package/lib/command/generate.js +197 -188
  19. package/lib/command/gherkin/init.js +27 -16
  20. package/lib/command/gherkin/snippets.js +21 -21
  21. package/lib/command/gherkin/steps.js +8 -8
  22. package/lib/command/info.js +40 -38
  23. package/lib/command/init.js +290 -288
  24. package/lib/command/interactive.js +32 -32
  25. package/lib/command/list.js +26 -26
  26. package/lib/command/run-multiple/chunk.js +5 -5
  27. package/lib/command/run-multiple/collection.js +3 -3
  28. package/lib/command/run-multiple/run.js +6 -2
  29. package/lib/command/run-multiple.js +113 -93
  30. package/lib/command/run-rerun.js +20 -25
  31. package/lib/command/run-workers.js +64 -66
  32. package/lib/command/run.js +26 -29
  33. package/lib/command/utils.js +80 -65
  34. package/lib/command/workers/runTests.js +11 -12
  35. package/lib/config.js +10 -9
  36. package/lib/container.js +40 -48
  37. package/lib/data/context.js +60 -59
  38. package/lib/data/dataScenarioConfig.js +47 -47
  39. package/lib/data/dataTableArgument.js +29 -29
  40. package/lib/data/table.js +26 -20
  41. package/lib/event.js +163 -167
  42. package/lib/heal.js +14 -18
  43. package/lib/helper/AI.js +130 -41
  44. package/lib/helper/ApiDataFactory.js +74 -70
  45. package/lib/helper/Appium.js +416 -388
  46. package/lib/helper/ExpectHelper.js +40 -48
  47. package/lib/helper/FileSystem.js +80 -79
  48. package/lib/helper/GraphQL.js +44 -43
  49. package/lib/helper/GraphQLDataFactory.js +51 -51
  50. package/lib/helper/JSONResponse.js +65 -62
  51. package/lib/helper/Mochawesome.js +28 -28
  52. package/lib/helper/Nightmare.js +664 -571
  53. package/lib/helper/Playwright.js +1367 -1222
  54. package/lib/helper/Protractor.js +663 -635
  55. package/lib/helper/Puppeteer.js +1232 -1132
  56. package/lib/helper/REST.js +183 -68
  57. package/lib/helper/SoftExpectHelper.js +2 -2
  58. package/lib/helper/TestCafe.js +490 -486
  59. package/lib/helper/WebDriver.js +1246 -1297
  60. package/lib/helper/clientscripts/PollyWebDriverExt.js +1 -1
  61. package/lib/helper/errors/ConnectionRefused.js +1 -1
  62. package/lib/helper/errors/ElementAssertion.js +2 -2
  63. package/lib/helper/errors/ElementNotFound.js +2 -2
  64. package/lib/helper/errors/RemoteBrowserConnectionRefused.js +1 -1
  65. package/lib/helper/extras/Console.js +1 -1
  66. package/lib/helper/extras/PlaywrightPropEngine.js +4 -4
  67. package/lib/helper/extras/PlaywrightReactVueLocator.js +1 -1
  68. package/lib/helper/extras/PlaywrightRestartOpts.js +21 -18
  69. package/lib/helper/extras/Popup.js +1 -1
  70. package/lib/helper/extras/React.js +3 -3
  71. package/lib/helper/network/actions.js +14 -7
  72. package/lib/helper/network/utils.js +4 -3
  73. package/lib/helper/scripts/blurElement.js +1 -1
  74. package/lib/helper/scripts/focusElement.js +1 -1
  75. package/lib/helper/scripts/highlightElement.js +1 -1
  76. package/lib/helper/scripts/isElementClickable.js +1 -1
  77. package/lib/helper/testcafe/testControllerHolder.js +1 -1
  78. package/lib/helper/testcafe/testcafe-utils.js +7 -8
  79. package/lib/helper.js +1 -3
  80. package/lib/history.js +6 -5
  81. package/lib/hooks.js +6 -6
  82. package/lib/html.js +7 -7
  83. package/lib/index.js +25 -41
  84. package/lib/interfaces/bdd.js +47 -64
  85. package/lib/interfaces/featureConfig.js +19 -19
  86. package/lib/interfaces/gherkin.js +124 -118
  87. package/lib/interfaces/scenarioConfig.js +29 -29
  88. package/lib/listener/artifacts.js +9 -9
  89. package/lib/listener/config.js +24 -24
  90. package/lib/listener/exit.js +12 -12
  91. package/lib/listener/helpers.js +42 -42
  92. package/lib/listener/mocha.js +11 -11
  93. package/lib/listener/retry.js +32 -30
  94. package/lib/listener/steps.js +50 -53
  95. package/lib/listener/timeout.js +54 -54
  96. package/lib/locator.js +7 -11
  97. package/lib/mochaFactory.js +18 -15
  98. package/lib/output.js +19 -15
  99. package/lib/parser.js +15 -12
  100. package/lib/pause.js +45 -38
  101. package/lib/plugin/allure.js +15 -15
  102. package/lib/plugin/autoDelay.js +29 -37
  103. package/lib/plugin/autoLogin.js +70 -65
  104. package/lib/plugin/commentStep.js +18 -18
  105. package/lib/plugin/coverage.js +112 -67
  106. package/lib/plugin/customLocator.js +21 -20
  107. package/lib/plugin/debugErrors.js +24 -24
  108. package/lib/plugin/eachElement.js +38 -38
  109. package/lib/plugin/fakerTransform.js +6 -6
  110. package/lib/plugin/heal.js +67 -108
  111. package/lib/plugin/pauseOnFail.js +11 -11
  112. package/lib/plugin/retryFailedStep.js +32 -39
  113. package/lib/plugin/retryTo.js +46 -40
  114. package/lib/plugin/screenshotOnFail.js +109 -87
  115. package/lib/plugin/selenoid.js +131 -118
  116. package/lib/plugin/standardActingHelpers.js +2 -8
  117. package/lib/plugin/stepByStepReport.js +110 -91
  118. package/lib/plugin/stepTimeout.js +24 -23
  119. package/lib/plugin/subtitles.js +34 -35
  120. package/lib/plugin/tryTo.js +40 -30
  121. package/lib/plugin/wdio.js +78 -75
  122. package/lib/recorder.js +14 -17
  123. package/lib/rerun.js +11 -10
  124. package/lib/scenario.js +25 -23
  125. package/lib/secret.js +4 -3
  126. package/lib/session.js +10 -10
  127. package/lib/step.js +12 -9
  128. package/lib/store.js +2 -3
  129. package/lib/transform.js +1 -1
  130. package/lib/translation.js +7 -8
  131. package/lib/ui.js +12 -14
  132. package/lib/utils.js +70 -72
  133. package/lib/within.js +10 -10
  134. package/lib/workerStorage.js +27 -25
  135. package/lib/workers.js +29 -33
  136. package/package.json +67 -68
  137. package/translations/de-DE.js +2 -1
  138. package/translations/fr-FR.js +2 -2
  139. package/translations/index.js +9 -13
  140. package/translations/it-IT.js +1 -1
  141. package/translations/ja-JP.js +1 -1
  142. package/translations/pl-PL.js +1 -1
  143. package/translations/pt-BR.js +1 -1
  144. package/translations/ru-RU.js +1 -1
  145. package/translations/zh-CN.js +1 -1
  146. package/translations/zh-TW.js +1 -1
  147. package/typings/index.d.ts +423 -65
  148. package/typings/promiseBasedTypes.d.ts +41 -172
  149. package/typings/types.d.ts +43 -178
  150. package/lib/dirname.js +0 -5
  151. package/lib/helper/Expect.js +0 -425
  152. package/lib/helper/MockServer.js +0 -223
@@ -108,4 +108,4 @@ const pollyWebDriver = {
108
108
  },
109
109
  };
110
110
 
111
- export default pollyWebDriver;
111
+ module.exports = pollyWebDriver;
@@ -7,4 +7,4 @@ function ConnectionRefused(err) {
7
7
 
8
8
  ConnectionRefused.prototype = Object.create(Error.prototype);
9
9
 
10
- export default ConnectionRefused;
10
+ module.exports = ConnectionRefused;
@@ -1,4 +1,4 @@
1
- import Locator from '../../locator.js';
1
+ const Locator = require('../../locator');
2
2
 
3
3
  const prefixMessage = 'Element';
4
4
 
@@ -30,7 +30,7 @@ function dontSeeElementInDOMError(locator) {
30
30
  throw new Error(`${prefixMessage} "${(new Locator(locator))}" is not seen in DOM.`);
31
31
  }
32
32
 
33
- export {
33
+ module.exports = {
34
34
  seeElementError,
35
35
  dontSeeElementError,
36
36
  seeElementInDOMError,
@@ -1,4 +1,4 @@
1
- import Locator from '../../locator.js';
1
+ const Locator = require('../../locator');
2
2
  /**
3
3
  * Uses to throw readable element not found error
4
4
  * Stringify object's locators
@@ -16,4 +16,4 @@ class ElementNotFound {
16
16
  }
17
17
  }
18
18
 
19
- export default ElementNotFound;
19
+ module.exports = ElementNotFound;
@@ -6,4 +6,4 @@ function RemoteBrowserConnectionRefused(err) {
6
6
 
7
7
  RemoteBrowserConnectionRefused.prototype = Object.create(Error.prototype);
8
8
 
9
- export default RemoteBrowserConnectionRefused;
9
+ module.exports = RemoteBrowserConnectionRefused;
@@ -30,4 +30,4 @@ class Console {
30
30
  }
31
31
  }
32
32
 
33
- export default Console;
33
+ module.exports = Console;
@@ -1,8 +1,8 @@
1
- export const createValueEngine = () => {
1
+ module.exports.createValueEngine = () => {
2
2
  return {
3
3
  // Creates a selector that matches given target when queried at the root.
4
4
  // Can return undefined if unable to create one.
5
- // eslint-disable-next-line no-unused-vars
5
+
6
6
  create(root, target) {
7
7
  return null;
8
8
  },
@@ -25,11 +25,11 @@ export const createValueEngine = () => {
25
25
  };
26
26
  };
27
27
 
28
- export const createDisabledEngine = () => {
28
+ module.exports.createDisabledEngine = () => {
29
29
  return {
30
30
  // Creates a selector that matches given target when queried at the root.
31
31
  // Can return undefined if unable to create one.
32
- // eslint-disable-next-line no-unused-vars
32
+
33
33
  create(root, target) {
34
34
  return null;
35
35
  },
@@ -40,4 +40,4 @@ function propBuilder(props) {
40
40
  return _props;
41
41
  }
42
42
 
43
- export { findReact, findVue, findByPlaywrightLocator };
43
+ module.exports = { findReact, findVue, findByPlaywrightLocator };
@@ -6,25 +6,28 @@ const RESTART_OPTS = {
6
6
 
7
7
  let restarts = null;
8
8
 
9
- export function setRestartStrategy(options) {
10
- const { restart } = options;
11
- const stringOpts = Object.keys(RESTART_OPTS);
9
+ module.exports = {
12
10
 
13
- if (stringOpts.includes(restart)) {
14
- return restarts = restart;
15
- }
11
+ setRestartStrategy(options) {
12
+ const { restart } = options;
13
+ const stringOpts = Object.keys(RESTART_OPTS);
16
14
 
17
- restarts = Object.keys(RESTART_OPTS).find(key => RESTART_OPTS[key] === restart);
15
+ if (stringOpts.includes(restart)) {
16
+ return restarts = restart;
17
+ }
18
18
 
19
- if (restarts === null || restarts === undefined) throw new Error('No restart strategy set, use the following values for restart: session, context, browser');
20
- }
19
+ restarts = Object.keys(RESTART_OPTS).find(key => RESTART_OPTS[key] === restart);
21
20
 
22
- export function restartsSession() {
23
- return restarts === 'session';
24
- }
25
- export function restartsContext() {
26
- return restarts === 'context';
27
- }
28
- export function restartsBrowser() {
29
- return restarts === 'browser';
30
- }
21
+ if (restarts === null || restarts === undefined) throw new Error('No restart strategy set, use the following values for restart: session, context, browser');
22
+ },
23
+
24
+ restartsSession() {
25
+ return restarts === 'session';
26
+ },
27
+ restartsContext() {
28
+ return restarts === 'context';
29
+ },
30
+ restartsBrowser() {
31
+ return restarts === 'browser';
32
+ },
33
+ };
@@ -64,4 +64,4 @@ class Popup {
64
64
  }
65
65
  }
66
66
 
67
- export default Popup;
67
+ module.exports = Popup;
@@ -1,8 +1,8 @@
1
- import fs from 'fs';
1
+ const fs = require('fs');
2
2
 
3
3
  let resqScript;
4
4
 
5
- export default async function findReact(matcher, locator) {
5
+ module.exports = async function findReact(matcher, locator) {
6
6
  if (!resqScript) resqScript = fs.readFileSync(require.resolve('resq'));
7
7
  await matcher.evaluate(resqScript.toString());
8
8
  await matcher
@@ -63,4 +63,4 @@ export default async function findReact(matcher, locator) {
63
63
  }
64
64
 
65
65
  return result;
66
- }
66
+ };
@@ -1,7 +1,7 @@
1
- import assert from 'assert'
2
- import { isInTraffic, createAdvancedTestResults, getTrafficDump } from './utils.js';
1
+ const assert = require('assert');
2
+ const { isInTraffic, createAdvancedTestResults, getTrafficDump } = require('./utils');
3
3
 
4
- export function dontSeeTraffic({ name, url }) {
4
+ function dontSeeTraffic({ name, url }) {
5
5
  if (!this.recordedAtLeastOnce) {
6
6
  throw new Error('Failure in test automation. You use "I.dontSeeTraffic", but "I.startRecordingTraffic" was never called before.');
7
7
  }
@@ -19,7 +19,7 @@ export function dontSeeTraffic({ name, url }) {
19
19
  }
20
20
  }
21
21
 
22
- export async function seeTraffic({
22
+ async function seeTraffic({
23
23
  name, url, parameters, requestPostData, timeout = 10,
24
24
  }) {
25
25
  if (!name) {
@@ -65,7 +65,7 @@ export async function seeTraffic({
65
65
  }
66
66
  }
67
67
 
68
- export async function grabRecordedNetworkTraffics() {
68
+ async function grabRecordedNetworkTraffics() {
69
69
  if (!this.recording || !this.recordedAtLeastOnce) {
70
70
  throw new Error('Failure in test automation. You use "I.grabRecordedNetworkTraffics", but "I.startRecordingTraffic" was never called before.');
71
71
  }
@@ -104,13 +104,20 @@ export async function grabRecordedNetworkTraffics() {
104
104
  return Promise.all(promises);
105
105
  }
106
106
 
107
- export function stopRecordingTraffic() {
107
+ function stopRecordingTraffic() {
108
108
  // @ts-ignore
109
109
  this.page.removeAllListeners('request');
110
110
  this.recording = false;
111
111
  }
112
112
 
113
- export function flushNetworkTraffics() {
113
+ function flushNetworkTraffics() {
114
114
  this.requests = [];
115
115
  }
116
116
 
117
+ module.exports = {
118
+ dontSeeTraffic,
119
+ seeTraffic,
120
+ grabRecordedNetworkTraffics,
121
+ stopRecordingTraffic,
122
+ flushNetworkTraffics,
123
+ };
@@ -34,7 +34,7 @@ const extractQueryObjects = (queryString) => {
34
34
  queryParameters.forEach((queryParameter) => {
35
35
  const keyValue = queryParameter.split('=');
36
36
  const queryObject = {};
37
- // eslint-disable-next-line prefer-destructuring
37
+
38
38
  queryObject.name = keyValue[0];
39
39
  queryObject.value = decodeURIComponent(keyValue[1]);
40
40
  queryObjects.push(queryObject);
@@ -135,7 +135,7 @@ const allRequestPostDataValuePairsMatchExtreme = (RequestPostDataObject, advance
135
135
  * @return {string} List of URLs recorded as a string, separated by new lines after each URL
136
136
  * @private
137
137
  */
138
- export function getTrafficDump() {
138
+ function getTrafficDump() {
139
139
  let dumpedTraffic = '';
140
140
  this.requests.forEach((request) => {
141
141
  dumpedTraffic += `${request.method} - ${request.url}\n`;
@@ -177,10 +177,11 @@ function isInTraffic(url, parameters) {
177
177
  return isInTraffic;
178
178
  }
179
179
 
180
- export {
180
+ module.exports = {
181
181
  createAdvancedTestResults,
182
182
  extractQueryObjects,
183
183
  allParameterValuePairsMatchExtreme,
184
184
  allRequestPostDataValuePairsMatchExtreme,
185
+ getTrafficDump,
185
186
  isInTraffic,
186
187
  };
@@ -1,4 +1,4 @@
1
- export const blurElement = (element, context) => {
1
+ module.exports.blurElement = (element, context) => {
2
2
  const clientSideBlurFn = el => {
3
3
  el.blur();
4
4
  };
@@ -1,4 +1,4 @@
1
- export const focusElement = (element, context) => {
1
+ module.exports.focusElement = (element, context) => {
2
2
  const clientSideFn = el => {
3
3
  el.focus();
4
4
  };
@@ -1,4 +1,4 @@
1
- export const highlightElement = (element, context) => {
1
+ module.exports.highlightElement = (element, context) => {
2
2
  const clientSideHighlightFn = el => {
3
3
  const style = '0px 0px 4px 3px rgba(255, 0, 0, 0.7)';
4
4
  const prevStyle = el.style.boxShadow;
@@ -61,4 +61,4 @@ function isElementClickable(element) {
61
61
  return element.disabled !== true && isElementInViewport(element) && isOverlappingElementMatch(getOverlappingElements(element), element);
62
62
  }
63
63
 
64
- export default isElementClickable;
64
+ module.exports = isElementClickable;
@@ -39,4 +39,4 @@ const testControllerHolder = {
39
39
  },
40
40
  };
41
41
 
42
- export default testControllerHolder;
42
+ module.exports = testControllerHolder;
@@ -1,10 +1,9 @@
1
- import { ClientFunction } from 'testcafe';
2
- import assert from 'assert';
3
- import fs from 'fs';
4
- import path from 'path';
5
- import { getParamNames } from '../../utils.js';
1
+ const { ClientFunction } = require('testcafe');
6
2
 
7
- const __dirname = path.resolve();
3
+ const assert = require('assert');
4
+ const fs = require('fs');
5
+ const path = require('path');
6
+ const { getParamNames } = require('../../utils');
8
7
 
9
8
  const createTestFile = () => {
10
9
  assert(global.output_dir, 'global.output_dir must be set');
@@ -49,14 +48,14 @@ function getFuncBody(func) {
49
48
  const arrowIndex = fnStr.indexOf('=>');
50
49
  if (arrowIndex >= 0) {
51
50
  fnStr = fnStr.slice(arrowIndex + 2);
52
- // eslint-disable-next-line no-new-func
51
+
53
52
  // eslint-disable-next-line no-eval
54
53
  return eval(`() => ${fnStr}`);
55
54
  }
56
55
  // TODO: support general functions
57
56
  }
58
57
 
59
- export default {
58
+ module.exports = {
60
59
  createTestFile,
61
60
  mapError,
62
61
  createClientFunction,
package/lib/helper.js CHANGED
@@ -1,4 +1,2 @@
1
1
  // helper class was moved out from this repository to allow extending from base class
2
- import generated from '@codeceptjs/helper';
3
-
4
- export default generated;
2
+ module.exports = require('@codeceptjs/helper');
package/lib/history.js CHANGED
@@ -1,7 +1,8 @@
1
- import colors from 'chalk';
2
- import fs from 'fs';
3
- import path from 'path';
4
- import * as output from './output.js';
1
+ const colors = require('chalk');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+
5
+ const output = require('./output');
5
6
 
6
7
  /**
7
8
  * REPL history records REPL commands and stores them in
@@ -48,4 +49,4 @@ class ReplHistory {
48
49
  }
49
50
  }
50
51
 
51
- export default new ReplHistory();
52
+ module.exports = new ReplHistory();
package/lib/hooks.js CHANGED
@@ -1,17 +1,17 @@
1
- import { isFunction, isAsyncFunction } from './utils.js';
2
- import * as output from './output.js';
1
+ const { isFunction, isAsyncFunction } = require('./utils');
2
+ const output = require('./output');
3
3
 
4
- export default async function (hook, stage) {
4
+ module.exports = async function (hook, stage) {
5
5
  if (!hook) return;
6
6
  if (!isFunction(hook)) {
7
7
  throw new Error('CodeceptJS 3 allows bootstrap/teardown hooks only as async functions. More info: https://bit.ly/codecept3Up');
8
8
  }
9
9
 
10
- if (stage) output.output.log(`started ${stage} hook`);
10
+ if (stage) output.log(`started ${stage} hook`);
11
11
  if (isAsyncFunction(hook)) {
12
12
  await hook();
13
13
  } else {
14
14
  hook();
15
15
  }
16
- if (stage) output.output.log(`finished ${stage} hook`);
17
- }
16
+ if (stage) output.log(`finished ${stage} hook`);
17
+ };
package/lib/html.js CHANGED
@@ -1,7 +1,7 @@
1
- import { parse, serialize } from 'parse5';
2
- import { minify } from 'html-minifier-terser';
1
+ const { parse, serialize } = require('parse5');
2
+ const { minify } = require('html-minifier-terser');
3
3
 
4
- export async function minifyHtml(html) {
4
+ async function minifyHtml(html) {
5
5
  return minify(html, {
6
6
  collapseWhitespace: true,
7
7
  removeComments: true,
@@ -21,7 +21,7 @@ const defaultHtmlOpts = {
21
21
  allowedRoles: ['button', 'checkbox', 'search', 'textbox', 'tab'],
22
22
  };
23
23
 
24
- export function removeNonInteractiveElements(html, opts = {}) {
24
+ function removeNonInteractiveElements(html, opts = {}) {
25
25
  opts = { ...defaultHtmlOpts, ...opts };
26
26
  const {
27
27
  interactiveElements,
@@ -142,7 +142,7 @@ export function removeNonInteractiveElements(html, opts = {}) {
142
142
  return serializedHTML;
143
143
  }
144
144
 
145
- export function scanForErrorMessages(html, errorClasses = []) {
145
+ function scanForErrorMessages(html, errorClasses = []) {
146
146
  // Parse the HTML into a document tree
147
147
  const document = parse(html);
148
148
 
@@ -216,7 +216,7 @@ function buildPath(node, path = '') {
216
216
  return path;
217
217
  }
218
218
 
219
- export function splitByChunks(text, chunkSize) {
219
+ function splitByChunks(text, chunkSize) {
220
220
  chunkSize -= 20;
221
221
  const chunks = [];
222
222
  for (let i = 0; i < text.length; i += chunkSize) {
@@ -250,7 +250,7 @@ export function splitByChunks(text, chunkSize) {
250
250
  return chunks.map(chunk => chunk.trim());
251
251
  }
252
252
 
253
- export default {
253
+ module.exports = {
254
254
  scanForErrorMessages,
255
255
  removeNonInteractiveElements,
256
256
  splitByChunks,
package/lib/index.js CHANGED
@@ -1,20 +1,3 @@
1
- import * as _codecept from './codecept.js';
2
- import * as workers from './workers.js';
3
- import * as dataTableArgument from './data/dataTableArgument.js';
4
- import * as dataTable from './data/table.js';
5
- import * as within from './within.js';
6
- import * as pause from './pause.js';
7
- import * as helper from './helper.js';
8
- import * as actor from './actor.js';
9
- import * as config from './config.js';
10
- import * as output from './output.js';
11
- import * as recorder from './recorder.js';
12
- import * as container from './container.js';
13
- import * as locator from './locator.js';
14
- import * as event from './event.js';
15
- import * as store from './store.js';
16
- import * as heal from './heal.js';
17
- import * as ai from './ai.js';
18
1
  /**
19
2
  * Index file for loading CodeceptJS programmatically.
20
3
  *
@@ -22,41 +5,42 @@ import * as ai from './ai.js';
22
5
  * @alias index
23
6
  * @namespace
24
7
  */
25
- /** @type {typeof CodeceptJS.Codecept} */
26
- export { _codecept as codecept };
27
- /** @type {typeof CodeceptJS.Codecept} */
28
- export { _codecept as Codecept };
29
- /** @type {typeof CodeceptJS.Helper} */
30
- export { helper as Helper };
31
- export { workers as Workers };
32
- export {
8
+ module.exports = {
9
+ /** @type {typeof CodeceptJS.Codecept} */
10
+ codecept: require('./codecept'),
11
+ /** @type {typeof CodeceptJS.Codecept} */
12
+ Codecept: require('./codecept'),
33
13
  /** @type {typeof CodeceptJS.output} */
34
- output,
14
+ output: require('./output'),
35
15
  /** @type {typeof CodeceptJS.Container} */
36
- container,
16
+ container: require('./container'),
37
17
  /** @type {typeof CodeceptJS.event} */
38
- event,
18
+ event: require('./event'),
39
19
  /** @type {CodeceptJS.recorder} */
40
- recorder,
20
+ recorder: require('./recorder'),
41
21
  /** @type {typeof CodeceptJS.Config} */
42
- config,
22
+ config: require('./config'),
43
23
  /** @type {CodeceptJS.actor} */
44
- actor,
24
+ actor: require('./actor'),
45
25
  /** @type {typeof CodeceptJS.Helper} */
46
- helper,
26
+ helper: require('./helper'),
27
+ /** @type {typeof CodeceptJS.Helper} */
28
+ Helper: require('./helper'),
47
29
  /** @type {typeof CodeceptJS.pause} */
48
- pause,
30
+ pause: require('./pause'),
49
31
  /** @type {typeof CodeceptJS.within} */
50
- within,
32
+ within: require('./within'),
51
33
  /** @type {typeof CodeceptJS.DataTable} */
52
- dataTable,
34
+ dataTable: require('./data/table'),
53
35
  /** @type {typeof CodeceptJS.DataTableArgument} */
54
- dataTableArgument,
36
+ dataTableArgument: require('./data/dataTableArgument'),
55
37
  /** @type {typeof CodeceptJS.store} */
56
- store,
38
+ store: require('./store'),
57
39
  /** @type {typeof CodeceptJS.Locator} */
58
- locator,
59
- heal,
60
- ai,
61
- workers,
40
+ locator: require('./locator'),
41
+
42
+ heal: require('./heal'),
43
+ ai: require('./ai'),
44
+
45
+ Workers: require('./workers'),
62
46
  };
@@ -1,98 +1,81 @@
1
- import { CucumberExpression, ParameterTypeRegistry, ParameterType } from '@cucumber/cucumber-expressions';
2
- import Config from '../config.js';
1
+ const { CucumberExpression, ParameterTypeRegistry, ParameterType } = require('@cucumber/cucumber-expressions')
2
+ const Config = require('../config')
3
3
 
4
- let steps = {};
5
- const codecept_dir = '';
4
+ let steps = {}
6
5
 
7
- const STACK_POSITION = 2;
6
+ const STACK_POSITION = 2
8
7
 
9
8
  /**
10
9
  * @param {*} step
11
10
  * @param {*} fn
12
11
  */
13
12
  const addStep = (step, fn) => {
14
- const avoidDuplicateSteps = Config.get('gherkin', {}).avoidDuplicateSteps || false;
15
- const stack = (new Error()).stack;
13
+ const avoidDuplicateSteps = Config.get('gherkin', {}).avoidDuplicateSteps || false
14
+ const stack = new Error().stack
16
15
  if (avoidDuplicateSteps && steps[step]) {
17
- throw new Error(`Step '${step}' is already defined`);
16
+ throw new Error(`Step '${step}' is already defined`)
18
17
  }
19
- steps[step] = fn;
20
- fn.line = stack && stack.split('\n')[STACK_POSITION];
18
+ steps[step] = fn
19
+ fn.line = stack && stack.split('\n')[STACK_POSITION]
21
20
  if (fn.line) {
22
21
  fn.line = fn.line
23
22
  .trim()
24
23
  .replace(/^at (.*?)\(/, '(')
25
- .replace(codecept_dir, '.');
24
+ .replace(codecept_dir, '.')
26
25
  }
27
- };
26
+ }
28
27
 
29
- const parameterTypeRegistry = new ParameterTypeRegistry();
28
+ const parameterTypeRegistry = new ParameterTypeRegistry()
30
29
 
31
- export const matchStep = (step) => {
30
+ const matchStep = (step) => {
32
31
  for (const stepName in steps) {
33
32
  if (stepName.indexOf('/') === 0) {
34
- const regExpArr = stepName.match(/^\/(.*?)\/([gimy]*)$/) || [];
35
- const res = step.match(new RegExp(regExpArr[1], regExpArr[2]));
33
+ const regExpArr = stepName.match(/^\/(.*?)\/([gimy]*)$/) || []
34
+ const res = step.match(new RegExp(regExpArr[1], regExpArr[2]))
36
35
  if (res) {
37
- const fn = steps[stepName];
38
- fn.params = res.slice(1);
39
- return fn;
36
+ const fn = steps[stepName]
37
+ fn.params = res.slice(1)
38
+ return fn
40
39
  }
41
- continue;
40
+ continue
42
41
  }
43
- const expression = new CucumberExpression(stepName, parameterTypeRegistry);
44
- // console.log(expression)
45
- // console.log((step))
46
- const res = expression.match(step);
42
+ const expression = new CucumberExpression(stepName, parameterTypeRegistry)
43
+ const res = expression.match(step)
47
44
  if (res) {
48
- const fn = steps[stepName];
49
- fn.params = res.map(arg => arg.getValue());
50
- return fn;
45
+ const fn = steps[stepName]
46
+ fn.params = res.map((arg) => arg.getValue())
47
+ return fn
51
48
  }
52
49
  }
53
- throw new Error(`No steps matching "${step.toString()}"`);
54
- };
50
+ throw new Error(`No steps matching "${step.toString()}"`)
51
+ }
55
52
 
56
- export const clearSteps = () => {
57
- steps = {};
58
- };
53
+ const clearSteps = () => {
54
+ steps = {}
55
+ }
59
56
 
60
- export const getSteps = () => {
61
- return steps;
62
- };
57
+ const getSteps = () => {
58
+ return steps
59
+ }
63
60
 
64
- export const defineParameterType = (options) => {
65
- const parameterType = buildParameterType(options);
66
- parameterTypeRegistry.defineParameterType(parameterType);
67
- };
61
+ const defineParameterType = (options) => {
62
+ const parameterType = buildParameterType(options)
63
+ parameterTypeRegistry.defineParameterType(parameterType)
64
+ }
68
65
 
69
- export const buildParameterType = ({
70
- name,
71
- regexp,
72
- transformer,
73
- useForSnippets,
74
- preferForRegexpMatch,
75
- }) => {
76
- if (typeof useForSnippets !== 'boolean') useForSnippets = true;
77
- if (typeof preferForRegexpMatch !== 'boolean') preferForRegexpMatch = false;
78
- return new ParameterType(
79
- name,
80
- regexp,
81
- null,
82
- transformer,
83
- useForSnippets,
84
- preferForRegexpMatch,
85
- );
86
- };
66
+ const buildParameterType = ({ name, regexp, transformer, useForSnippets, preferForRegexpMatch }) => {
67
+ if (typeof useForSnippets !== 'boolean') useForSnippets = true
68
+ if (typeof preferForRegexpMatch !== 'boolean') preferForRegexpMatch = false
69
+ return new ParameterType(name, regexp, null, transformer, useForSnippets, preferForRegexpMatch)
70
+ }
87
71
 
88
- export { addStep as Given };
89
- export { addStep as When };
90
- export { addStep as Then };
91
- export { addStep as And };
92
-
93
- export default {
72
+ module.exports = {
73
+ Given: addStep,
74
+ When: addStep,
75
+ Then: addStep,
76
+ And: addStep,
94
77
  matchStep,
95
78
  getSteps,
96
79
  clearSteps,
97
80
  defineParameterType,
98
- };
81
+ }