codeceptjs 3.6.7 → 4.0.0-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.
Files changed (149) hide show
  1. package/bin/codecept.js +81 -84
  2. package/lib/actor.js +13 -13
  3. package/lib/ai.js +13 -10
  4. package/lib/assert/empty.js +21 -20
  5. package/lib/assert/equal.js +39 -37
  6. package/lib/assert/error.js +14 -14
  7. package/lib/assert/include.js +47 -46
  8. package/lib/assert/throws.js +11 -13
  9. package/lib/assert/truth.js +22 -19
  10. package/lib/assert.js +2 -4
  11. package/lib/cli.js +49 -57
  12. package/lib/codecept.js +155 -142
  13. package/lib/colorUtils.js +3 -3
  14. package/lib/command/configMigrate.js +52 -58
  15. package/lib/command/definitions.js +89 -88
  16. package/lib/command/dryRun.js +68 -71
  17. package/lib/command/generate.js +188 -197
  18. package/lib/command/gherkin/init.js +16 -27
  19. package/lib/command/gherkin/snippets.js +20 -20
  20. package/lib/command/gherkin/steps.js +8 -8
  21. package/lib/command/info.js +38 -40
  22. package/lib/command/init.js +288 -290
  23. package/lib/command/interactive.js +32 -32
  24. package/lib/command/list.js +26 -26
  25. package/lib/command/run-multiple/chunk.js +5 -5
  26. package/lib/command/run-multiple/collection.js +3 -3
  27. package/lib/command/run-multiple/run.js +2 -6
  28. package/lib/command/run-multiple.js +93 -113
  29. package/lib/command/run-rerun.js +25 -20
  30. package/lib/command/run-workers.js +66 -64
  31. package/lib/command/run.js +29 -26
  32. package/lib/command/utils.js +65 -80
  33. package/lib/command/workers/runTests.js +10 -10
  34. package/lib/config.js +9 -10
  35. package/lib/container.js +48 -40
  36. package/lib/data/context.js +59 -60
  37. package/lib/data/dataScenarioConfig.js +47 -47
  38. package/lib/data/dataTableArgument.js +29 -29
  39. package/lib/data/table.js +20 -26
  40. package/lib/dirname.js +5 -0
  41. package/lib/event.js +167 -163
  42. package/lib/heal.js +17 -13
  43. package/lib/helper/AI.js +41 -130
  44. package/lib/helper/ApiDataFactory.js +69 -73
  45. package/lib/helper/Appium.js +381 -412
  46. package/lib/helper/Expect.js +425 -0
  47. package/lib/helper/ExpectHelper.js +48 -40
  48. package/lib/helper/FileSystem.js +79 -80
  49. package/lib/helper/GraphQL.js +43 -44
  50. package/lib/helper/GraphQLDataFactory.js +50 -50
  51. package/lib/helper/JSONResponse.js +62 -65
  52. package/lib/helper/Mochawesome.js +28 -28
  53. package/lib/helper/MockServer.js +14 -12
  54. package/lib/helper/Nightmare.js +566 -662
  55. package/lib/helper/Playwright.js +1216 -1361
  56. package/lib/helper/Protractor.js +627 -663
  57. package/lib/helper/Puppeteer.js +1128 -1231
  58. package/lib/helper/REST.js +68 -159
  59. package/lib/helper/SoftExpectHelper.js +2 -2
  60. package/lib/helper/TestCafe.js +484 -490
  61. package/lib/helper/WebDriver.js +1156 -1297
  62. package/lib/helper/clientscripts/PollyWebDriverExt.js +1 -1
  63. package/lib/helper/errors/ConnectionRefused.js +1 -1
  64. package/lib/helper/errors/ElementAssertion.js +2 -2
  65. package/lib/helper/errors/ElementNotFound.js +2 -2
  66. package/lib/helper/errors/RemoteBrowserConnectionRefused.js +1 -1
  67. package/lib/helper/extras/Console.js +1 -1
  68. package/lib/helper/extras/PlaywrightPropEngine.js +2 -2
  69. package/lib/helper/extras/PlaywrightReactVueLocator.js +1 -1
  70. package/lib/helper/extras/PlaywrightRestartOpts.js +18 -21
  71. package/lib/helper/extras/Popup.js +1 -1
  72. package/lib/helper/extras/React.js +3 -3
  73. package/lib/helper/network/actions.js +7 -14
  74. package/lib/helper/network/utils.js +2 -3
  75. package/lib/helper/scripts/blurElement.js +1 -1
  76. package/lib/helper/scripts/focusElement.js +1 -1
  77. package/lib/helper/scripts/highlightElement.js +1 -1
  78. package/lib/helper/scripts/isElementClickable.js +1 -1
  79. package/lib/helper/testcafe/testControllerHolder.js +1 -1
  80. package/lib/helper/testcafe/testcafe-utils.js +7 -6
  81. package/lib/helper.js +3 -1
  82. package/lib/history.js +5 -6
  83. package/lib/hooks.js +6 -6
  84. package/lib/html.js +7 -7
  85. package/lib/index.js +41 -25
  86. package/lib/interfaces/bdd.js +64 -47
  87. package/lib/interfaces/featureConfig.js +19 -19
  88. package/lib/interfaces/gherkin.js +118 -124
  89. package/lib/interfaces/scenarioConfig.js +29 -29
  90. package/lib/listener/artifacts.js +9 -9
  91. package/lib/listener/config.js +24 -24
  92. package/lib/listener/exit.js +12 -12
  93. package/lib/listener/helpers.js +42 -42
  94. package/lib/listener/mocha.js +11 -11
  95. package/lib/listener/retry.js +30 -32
  96. package/lib/listener/steps.js +53 -50
  97. package/lib/listener/timeout.js +54 -54
  98. package/lib/locator.js +10 -6
  99. package/lib/mochaFactory.js +15 -18
  100. package/lib/output.js +10 -6
  101. package/lib/parser.js +12 -15
  102. package/lib/pause.js +33 -40
  103. package/lib/plugin/allure.js +15 -15
  104. package/lib/plugin/autoDelay.js +37 -29
  105. package/lib/plugin/autoLogin.js +65 -70
  106. package/lib/plugin/commentStep.js +18 -18
  107. package/lib/plugin/coverage.js +67 -115
  108. package/lib/plugin/customLocator.js +20 -21
  109. package/lib/plugin/debugErrors.js +24 -24
  110. package/lib/plugin/eachElement.js +38 -38
  111. package/lib/plugin/fakerTransform.js +6 -6
  112. package/lib/plugin/heal.js +108 -67
  113. package/lib/plugin/pauseOnFail.js +11 -11
  114. package/lib/plugin/retryFailedStep.js +39 -32
  115. package/lib/plugin/retryTo.js +40 -46
  116. package/lib/plugin/screenshotOnFail.js +87 -109
  117. package/lib/plugin/selenoid.js +118 -131
  118. package/lib/plugin/standardActingHelpers.js +8 -2
  119. package/lib/plugin/stepByStepReport.js +91 -110
  120. package/lib/plugin/stepTimeout.js +23 -24
  121. package/lib/plugin/subtitles.js +35 -34
  122. package/lib/plugin/tryTo.js +30 -40
  123. package/lib/plugin/wdio.js +75 -78
  124. package/lib/recorder.js +17 -14
  125. package/lib/rerun.js +10 -11
  126. package/lib/scenario.js +23 -25
  127. package/lib/secret.js +2 -4
  128. package/lib/session.js +10 -10
  129. package/lib/step.js +9 -12
  130. package/lib/store.js +3 -2
  131. package/lib/transform.js +1 -1
  132. package/lib/translation.js +8 -7
  133. package/lib/ui.js +14 -12
  134. package/lib/utils.js +72 -70
  135. package/lib/within.js +10 -10
  136. package/lib/workerStorage.js +25 -27
  137. package/lib/workers.js +32 -29
  138. package/package.json +53 -51
  139. package/translations/de-DE.js +1 -1
  140. package/translations/fr-FR.js +1 -1
  141. package/translations/index.js +13 -9
  142. package/translations/it-IT.js +1 -1
  143. package/translations/ja-JP.js +1 -1
  144. package/translations/pl-PL.js +1 -1
  145. package/translations/pt-BR.js +1 -1
  146. package/translations/ru-RU.js +1 -1
  147. package/translations/zh-CN.js +1 -1
  148. package/translations/zh-TW.js +1 -1
  149. package/typings/index.d.ts +65 -415
@@ -1,78 +1,79 @@
1
- const Assertion = require('../assert')
2
- const AssertionFailedError = require('./error')
3
- const { template } = require('../utils')
4
- const output = require('../output')
1
+ import Assertion from '../assert.js';
2
+ import AssertionFailedError from './error.js';
3
+ import { template } from '../utils.js';
4
+ import * as output from '../output.js';
5
5
 
6
- const MAX_LINES = 10
6
+ const MAX_LINES = 10;
7
7
 
8
8
  class InclusionAssertion extends Assertion {
9
9
  constructor(params) {
10
- params.jar = params.jar || 'string'
10
+ params.jar = params.jar || 'string';
11
11
  const comparator = function (needle, haystack) {
12
12
  if (Array.isArray(haystack)) {
13
- return haystack.filter((part) => part.indexOf(needle) >= 0).length > 0
13
+ return haystack.filter(part => part.indexOf(needle) >= 0).length > 0;
14
14
  }
15
- return haystack.indexOf(needle) >= 0
16
- }
17
- super(comparator, params)
18
- this.params.type = 'to include'
15
+ return haystack.indexOf(needle) >= 0;
16
+ };
17
+ super(comparator, params);
18
+ this.params.type = 'to include';
19
19
  }
20
20
 
21
21
  getException() {
22
- const params = this.params
23
- params.jar = template(params.jar, params)
24
- const err = new AssertionFailedError(params, '{{customMessage}}expected {{jar}} {{type}} "{{needle}}"')
25
- err.expected = params.needle
26
- err.actual = params.haystack
22
+ const params = this.params;
23
+ params.jar = template(params.jar, params);
24
+ const err = new AssertionFailedError(params, '{{customMessage}}expected {{jar}} {{type}} "{{needle}}"');
25
+ err.expected = params.needle;
26
+ err.actual = params.haystack;
27
27
  if (Array.isArray(this.params.haystack)) {
28
- this.params.haystack = this.params.haystack.join('\n___(next element)___\n')
28
+ this.params.haystack = this.params.haystack.join('\n___(next element)___\n');
29
29
  }
30
30
  err.cliMessage = function () {
31
31
  const msg = this.template
32
- .replace('{{jar}}', output.colors.bold('{{jar}}'))
33
- .replace('{{needle}}', output.colors.bold('{{needle}}'))
34
- return template(msg, this.params)
35
- }
36
- return err
32
+ .replace('{{jar}}', output.output.colors.bold('{{jar}}'))
33
+ .replace('{{needle}}', output.output.colors.bold('{{needle}}'));
34
+ return template(msg, this.params);
35
+ };
36
+ return err;
37
37
  }
38
38
 
39
39
  getFailedAssertion() {
40
- const err = this.getException()
41
- const lines = this.params.haystack.split('\n')
40
+ const err = this.getException();
41
+ const lines = this.params.haystack.split('\n');
42
42
  if (lines.length > MAX_LINES) {
43
- const more = lines.length - MAX_LINES
44
- err.actual = `${lines.slice(0, MAX_LINES).join('\n')}\n--( ${more} lines more )---`
43
+ const more = lines.length - MAX_LINES;
44
+ err.actual = `${lines.slice(0, MAX_LINES).join('\n')}\n--( ${more} lines more )---`;
45
45
  }
46
- return err
46
+ return err;
47
47
  }
48
48
 
49
49
  getFailedNegation() {
50
- this.params.type = 'not to include'
51
- const err = this.getException()
52
- const pattern = new RegExp(`^.*?\n?^.*?\n?^.*?${escapeRegExp(this.params.needle)}.*?$\n?.*$\n?.*$`, 'm')
53
- const matched = this.params.haystack.match(pattern)
54
- if (!matched) return err
55
- err.actual = matched[0].replace(this.params.needle, output.colors.bold(this.params.needle))
56
- err.actual = `------\n${err.actual}\n------`
57
- return err
50
+ this.params.type = 'not to include';
51
+ const err = this.getException();
52
+ const pattern = new RegExp(`^.*?\n?^.*?\n?^.*?${escapeRegExp(this.params.needle)}.*?$\n?.*$\n?.*$`, 'm');
53
+ const matched = this.params.haystack.match(pattern);
54
+ if (!matched) return err;
55
+ err.actual = matched[0].replace(this.params.needle, output.output.colors.bold(this.params.needle));
56
+ err.actual = `------\n${err.actual}\n------`;
57
+ return err;
58
58
  }
59
59
 
60
60
  addAssertParams() {
61
- this.params.needle = arguments[0]
62
- this.params.haystack = arguments[1]
63
- this.params.customMessage = arguments[2] ? `${arguments[2]}\n\n` : ''
61
+ this.params.needle = arguments[0];
62
+ this.params.haystack = arguments[1];
63
+ this.params.customMessage = arguments[2] ? `${arguments[2]}\n\n` : '';
64
64
  }
65
65
  }
66
66
 
67
- module.exports = {
68
- Assertion: InclusionAssertion,
69
- includes: (needleType) => {
70
- needleType = needleType || 'string'
71
- return new InclusionAssertion({ jar: needleType })
72
- },
73
- fileIncludes: (file) => new InclusionAssertion({ file, jar: 'file {{file}}' }),
67
+ export { InclusionAssertion as Assertion };
68
+ export function includes(needleType) {
69
+ needleType = needleType || 'string';
70
+ return new InclusionAssertion({ jar: needleType });
74
71
  }
75
72
 
76
73
  function escapeRegExp(str) {
77
- return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&')
74
+ return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
75
+ }
76
+
77
+ export function fileIncludes(file) {
78
+ return new InclusionAssertion({ file, jar: 'file {{file}}' });
78
79
  }
@@ -1,22 +1,20 @@
1
1
  function errorThrown(actual, expected) {
2
- if (!expected) return null
3
- if (!actual) throw new Error(`Expected ${expected} error to be thrown`)
4
- const msg = actual.inspect ? actual.inspect() : actual.toString()
2
+ if (!expected) return null;
3
+ if (!actual) throw new Error(`Expected ${expected} error to be thrown`);
4
+ const msg = actual.inspect ? actual.inspect() : actual.toString();
5
5
  if (expected instanceof RegExp) {
6
- if (msg.match(expected)) return null
7
- throw new Error(`Expected error to be thrown with message matching ${expected} while '${msg}' caught`)
6
+ if (msg.match(expected)) return null;
7
+ throw new Error(`Expected error to be thrown with message matching ${expected} while '${msg}' caught`);
8
8
  }
9
9
  if (typeof expected === 'string') {
10
- if (msg === expected) return null
11
- throw new Error(`Expected error to be thrown with message ${expected} while '${msg}' caught`)
10
+ if (msg === expected) return null;
11
+ throw new Error(`Expected error to be thrown with message ${expected} while '${msg}' caught`);
12
12
  }
13
13
  if (typeof expected === 'object') {
14
- if (actual.constructor.name !== expected.constructor.name)
15
- throw new Error(`Expected ${expected} error to be thrown but ${actual} was caught`)
16
- if (expected.message && expected.message !== msg)
17
- throw new Error(`Expected error to be thrown with message ${expected.message} while '${msg}' caught`)
14
+ if (actual.constructor.name !== expected.constructor.name) throw new Error(`Expected ${expected} error to be thrown but ${actual} was caught`);
15
+ if (expected.message && expected.message !== msg) throw new Error(`Expected error to be thrown with message ${expected.message} while '${msg}' caught`);
18
16
  }
19
- return null
17
+ return null;
20
18
  }
21
19
 
22
- module.exports = errorThrown
20
+ export default errorThrown;
@@ -1,36 +1,39 @@
1
- const Assertion = require('../assert')
2
- const AssertionFailedError = require('./error')
3
- const { template } = require('../utils')
4
- const output = require('../output')
1
+ import Assertion from '../assert.js';
2
+ import AssertionFailedError from './error.js';
3
+ import { template } from '../utils.js';
4
+ import * as output from '../output.js';
5
5
 
6
6
  class TruthAssertion extends Assertion {
7
7
  constructor(params) {
8
8
  super((value) => {
9
9
  if (Array.isArray(value)) {
10
- return value.filter((val) => !!val).length > 0
10
+ return value.filter(val => !!val).length > 0;
11
11
  }
12
- return !!value
13
- }, params)
14
- this.params.type = this.params.type || 'to be true'
12
+ return !!value;
13
+ }, params);
14
+ this.params.type = this.params.type || 'to be true';
15
15
  }
16
16
 
17
17
  getException() {
18
- const err = new AssertionFailedError(this.params, '{{customMessage}}expected {{subject}} {{type}}')
18
+ const err = new AssertionFailedError(this.params, '{{customMessage}}expected {{subject}} {{type}}');
19
19
  err.cliMessage = () => {
20
- const msg = err.template.replace('{{subject}}', output.colors.bold('{{subject}}'))
21
- return template(msg, this.params)
22
- }
23
- return err
20
+ const msg = err.template
21
+ .replace('{{subject}}', output.colors.bold('{{subject}}'));
22
+ return template(msg, this.params);
23
+ };
24
+ return err;
24
25
  }
25
26
 
26
27
  addAssertParams() {
27
- this.params.value = this.params.actual = arguments[0]
28
- this.params.expected = true
29
- this.params.customMessage = arguments[1] ? `${arguments[1]}\n\n` : ''
28
+ this.params.value = this.params.actual = arguments[0];
29
+ this.params.expected = true;
30
+ this.params.customMessage = arguments[1] ? `${arguments[1]}\n\n` : '';
30
31
  }
31
32
  }
32
33
 
33
- module.exports = {
34
- Assertion: TruthAssertion,
35
- truth: (subject, type) => new TruthAssertion({ subject, type }),
34
+ export function truth(subject, type) {
35
+ return new TruthAssertion({ subject, type });
36
36
  }
37
+ export default {
38
+ Assertion: TruthAssertion,
39
+ };
package/lib/assert.js CHANGED
@@ -1,4 +1,4 @@
1
- const AssertionFailedError = require('./assert/error');
1
+ import AssertionFailedError from './assert/error.js';
2
2
 
3
3
  /**
4
4
  * Abstract assertion class introduced for more verbose and customizable messages.
@@ -20,7 +20,7 @@ const AssertionFailedError = require('./assert/error');
20
20
  * to get more customizable exception messages.
21
21
  *
22
22
  */
23
- class Assertion {
23
+ export default class Assertion {
24
24
  constructor(comparator, params) {
25
25
  this.comparator = comparator;
26
26
  this.params = params || {};
@@ -68,5 +68,3 @@ class Assertion {
68
68
  return this.getException();
69
69
  }
70
70
  }
71
-
72
- module.exports = Assertion;
package/lib/cli.js CHANGED
@@ -1,9 +1,12 @@
1
- const { reporters: { Base } } = require('mocha');
2
- const ms = require('ms');
3
- const event = require('./event');
4
- const AssertionFailedError = require('./assert/error');
5
- const output = require('./output');
6
- const { MetaStep } = require('./step');
1
+ import mocha from 'mocha';
2
+ import ms from 'ms';
3
+ import * as event from './event.js';
4
+ import * as output from './output.js';
5
+ import AssertionFailedError from './assert/error.js';
6
+ import * as Codecept from './codecept.js';
7
+ import container from './container.js';
8
+
9
+ const { reporters: { Base } } = mocha;
7
10
 
8
11
  const cursor = Base.cursor;
9
12
  let currentMetaStep = [];
@@ -18,16 +21,16 @@ class Cli extends Base {
18
21
  if (opts.steps) level = 1;
19
22
  if (opts.debug) level = 2;
20
23
  if (opts.verbose) level = 3;
21
- output.level(level);
22
- output.print(`CodeceptJS v${require('./codecept').version()} ${output.standWithUkraine()}`);
23
- output.print(`Using test root "${global.codecept_dir}"`);
24
+ output.output.level(level);
25
+ const version = Codecept.version();
26
+ output.output.print(`CodeceptJS v${version} ${output.output.standWithUkraine()}`);
27
+ output.output.print(`Using test root "${global.codecept_dir}"`);
24
28
 
25
29
  const showSteps = level >= 1;
26
30
 
27
31
  if (level >= 2) {
28
- const Containter = require('./container');
29
- output.print(output.styles.debug(`Helpers: ${Object.keys(Containter.helpers()).join(', ')}`));
30
- output.print(output.styles.debug(`Plugins: ${Object.keys(Containter.plugins()).join(', ')}`));
32
+ output.output.print(output.output.styles.debug(`Helpers: ${Object.keys(container.helpers()).join(', ')}`));
33
+ output.output.print(output.output.styles.debug(`Plugins: ${Object.keys(container.plugins()).join(', ')}`));
31
34
  }
32
35
 
33
36
  runner.on('start', () => {
@@ -35,7 +38,7 @@ class Cli extends Base {
35
38
  });
36
39
 
37
40
  runner.on('suite', (suite) => {
38
- output.suite.started(suite);
41
+ output.output.suite.started(suite);
39
42
  });
40
43
 
41
44
  runner.on('fail', (test) => {
@@ -43,10 +46,10 @@ class Cli extends Base {
43
46
  this.loadedTests.push(test.ctx.currentTest.uid);
44
47
  }
45
48
  if (showSteps && test.steps) {
46
- return output.scenario.failed(test);
49
+ return output.output.scenario.failed(test);
47
50
  }
48
51
  cursor.CR();
49
- output.test.failed(test);
52
+ output.output.test.failed(test);
50
53
  });
51
54
 
52
55
  runner.on('pending', (test) => {
@@ -59,22 +62,22 @@ class Cli extends Base {
59
62
  }
60
63
  this.loadedTests.push(test.uid);
61
64
  cursor.CR();
62
- output.test.skipped(test);
65
+ output.output.test.skipped(test);
63
66
  });
64
67
 
65
68
  runner.on('pass', (test) => {
66
69
  if (showSteps && test.steps) {
67
- return output.scenario.passed(test);
70
+ return output.output.scenario.passed(test);
68
71
  }
69
72
  cursor.CR();
70
- output.test.passed(test);
73
+ output.output.test.passed(test);
71
74
  });
72
75
 
73
76
  if (showSteps) {
74
77
  runner.on('test', (test) => {
75
78
  currentMetaStep = [];
76
79
  if (test.steps) {
77
- output.test.started(test);
80
+ output.output.test.started(test);
78
81
  }
79
82
  });
80
83
 
@@ -82,8 +85,8 @@ class Cli extends Base {
82
85
  codeceptjsEventDispatchersRegistered = true;
83
86
 
84
87
  event.dispatcher.on(event.bddStep.started, (step) => {
85
- output.stepShift = 2;
86
- output.step(step);
88
+ output.output.stepShift = 2;
89
+ output.output.step(step);
87
90
  });
88
91
 
89
92
  event.dispatcher.on(event.step.started, (step) => {
@@ -97,22 +100,22 @@ class Cli extends Base {
97
100
 
98
101
  for (let i = 0; i < Math.max(currentMetaStep.length, metaSteps.length); i++) {
99
102
  if (currentMetaStep[i] !== metaSteps[i]) {
100
- output.stepShift = 3 + 2 * i;
103
+ output.output.stepShift = 3 + 2 * i;
101
104
  if (!metaSteps[i]) continue;
102
105
  // bdd steps are handled by bddStep.started
103
106
  if (metaSteps[i].isBDD()) continue;
104
- output.step(metaSteps[i]);
107
+ output.output.step(metaSteps[i]);
105
108
  }
106
109
  }
107
110
  currentMetaStep = metaSteps;
108
- output.stepShift = 3 + 2 * shift;
111
+ output.output.stepShift = 3 + 2 * shift;
109
112
  if (step.helper.constructor.name !== 'ExpectHelper') {
110
- output.step(step);
113
+ output.output.step(step);
111
114
  }
112
115
  });
113
116
 
114
117
  event.dispatcher.on(event.step.finished, () => {
115
- output.stepShift = 0;
118
+ output.output.stepShift = 0;
116
119
  });
117
120
  }
118
121
  }
@@ -130,7 +133,7 @@ class Cli extends Base {
130
133
  test.opts.skipInfo = {};
131
134
  }
132
135
  skipTestConfig(test, 'Skipped due to failure in \'before\' hook');
133
- output.test.skipped(test);
136
+ output.output.test.skipped(test);
134
137
  skippedCount += 1;
135
138
  }
136
139
  }
@@ -145,12 +148,11 @@ class Cli extends Base {
145
148
 
146
149
  result() {
147
150
  const stats = this.stats;
148
- stats.failedHooks = 0;
149
151
  console.log();
150
152
 
151
153
  // passes
152
154
  if (stats.failures) {
153
- output.print(output.styles.bold('-- FAILURES:'));
155
+ output.output.print(output.output.styles.bold('-- FAILURES:'));
154
156
  }
155
157
 
156
158
  const failuresLog = [];
@@ -176,35 +178,31 @@ class Cli extends Base {
176
178
  // if (step.status === 'failed') line = '' + line;
177
179
  scenarioTrace += `\n${line}`;
178
180
  });
179
- log += `${output.styles.bold('Scenario Steps')}:${scenarioTrace}\n`;
181
+ log += `${output.output.styles.bold('Scenario Steps')}:${scenarioTrace}\n`;
180
182
  }
181
183
 
182
184
  // display artifacts in debug mode
183
185
  if (test?.artifacts && Object.keys(test.artifacts).length) {
184
- log += `\n${output.styles.bold('Artifacts:')}`;
186
+ log += `\n${output.output.styles.bold('Artifacts:')}`;
185
187
  for (const artifact of Object.keys(test.artifacts)) {
186
188
  log += `\n- ${artifact}: ${test.artifacts[artifact]}`;
187
189
  }
188
190
  }
189
191
 
190
- try {
191
- let stack = err.stack ? err.stack.split('\n') : [];
192
- if (stack[0] && stack[0].includes(err.message)) {
193
- stack.shift();
194
- }
192
+ let stack = err.stack ? err.stack.split('\n') : [];
193
+ if (stack[0] && stack[0].includes(err.message)) {
194
+ stack.shift();
195
+ }
195
196
 
196
- if (output.level() < 3) {
197
- stack = stack.slice(0, 3);
198
- }
197
+ if (output.output.level() < 3) {
198
+ stack = stack.slice(0, 3);
199
+ }
199
200
 
200
- err.stack = `${stack.join('\n')}\n\n${output.colors.blue(log)}`;
201
+ err.stack = `${stack.join('\n')}\n\n${output.output.colors.blue(log)}`;
201
202
 
202
- // clone err object so stack trace adjustments won't affect test other reports
203
- test.err = err;
204
- return test;
205
- } catch (e) {
206
- throw Error(e);
207
- }
203
+ // clone err object so stack trace adjustments won't affect test other reports
204
+ test.err = err;
205
+ return test;
208
206
  });
209
207
 
210
208
  const originalLog = Base.consoleLog;
@@ -217,17 +215,11 @@ class Cli extends Base {
217
215
  console.log();
218
216
  }
219
217
 
220
- this.failures.forEach((failure) => {
221
- if (failure.constructor.name === 'Hook') {
222
- stats.failures -= stats.failures
223
- stats.failedHooks += 1
224
- }
225
- })
226
218
  event.emit(event.all.failures, { failuresLog, stats });
227
- output.result(stats.passes, stats.failures, stats.pending, ms(stats.duration), stats.failedHooks);
219
+ output.output.result(stats.passes, stats.failures, stats.pending, ms(stats.duration));
228
220
 
229
- if (stats.failures && output.level() < 3) {
230
- output.print(output.styles.debug('Run with --verbose flag to see complete NodeJS stacktrace'));
221
+ if (stats.failures && output.output.level() < 3) {
222
+ output.output.print(output.output.styles.debug('Run with --verbose flag to see complete NodeJS stacktrace'));
231
223
  }
232
224
  }
233
225
  }
@@ -252,6 +244,6 @@ function skipTestConfig(test, message) {
252
244
  test.state = 'skipped';
253
245
  }
254
246
 
255
- module.exports = function (runner, opts) {
247
+ export default function cli(runner, opts) {
256
248
  return new Cli(runner, opts);
257
- };
249
+ }