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
package/lib/codecept.js CHANGED
@@ -1,228 +1,218 @@
1
- import { existsSync, readFileSync } from 'fs';
2
- import glob from 'glob';
3
- import { resolve, dirname, isAbsolute, join } from 'path';
4
- import { fileURLToPath } from 'url';
5
- import { createRequire } from 'node:module';
6
- import container from './container.js';
7
- import Config from './config.js';
8
- import * as event from './event.js';
9
- import runHook from './hooks.js';
10
- import * as output from './output.js';
11
- import { emptyFolder } from './utils.js';
12
- import * as index from './index.js';
13
-
14
- // Helpers and features
15
- import * as actor from './actor.js';
16
- import pause from './pause.js';
17
- import within from './within.js';
18
- import session from './session.js';
19
- import data from './data/table.js';
20
- import Locator from './locator.js';
21
- import secret from './secret.js';
22
- import * as stepDefinitions from './interfaces/bdd.js';
23
-
24
- // Listeners
25
- import listener from './listener/steps.js';
26
- import listenerArtifacts from './listener/artifacts.js';
27
- import listenerConfig from './listener/config.js';
28
- import listenerHelpers from './listener/helpers.js';
29
- import listenerRetry from './listener/retry.js';
30
- import listenerTimeout from './listener/timeout.js';
31
- import listenerExit from './listener/exit.js';
32
-
33
- const __dirname = dirname(fileURLToPath(import.meta.url));
34
- const require = createRequire(import.meta.url);
1
+ const { existsSync, readFileSync } = require('fs');
2
+ const glob = require('glob');
3
+ const fsPath = require('path');
4
+ const { resolve } = require('path');
5
+
6
+ const container = require('./container');
7
+ const Config = require('./config');
8
+ const event = require('./event');
9
+ const runHook = require('./hooks');
10
+ const output = require('./output');
11
+ const { emptyFolder } = require('./utils');
35
12
 
36
13
  /**
37
- * CodeceptJS runner class.
14
+ * CodeceptJS runner
38
15
  */
39
- export default class Codecept {
16
+ class Codecept {
40
17
  /**
41
- * Initializes CodeceptJS runner with config and options.
42
- * @param {Object} config - Configuration object.
43
- * @param {Object} opts - Options.
18
+ * Create CodeceptJS runner.
19
+ * Config and options should be passed
20
+ *
21
+ * @param {*} config
22
+ * @param {*} opts
44
23
  */
45
24
  constructor(config, opts) {
46
25
  this.config = Config.create(config);
47
26
  this.opts = opts;
48
- this.testFiles = [];
49
- this.requireModules(config?.require);
27
+ this.testFiles = new Array(0);
28
+ this.requireModules(config.require);
50
29
  }
51
30
 
52
31
  /**
53
- * Requires necessary modules before running CodeceptJS.
54
- * @param {string[]} requiringModules - List of modules to require.
32
+ * Require modules before codeceptjs running
33
+ *
34
+ * @param {string[]} requiringModules
55
35
  */
56
36
  requireModules(requiringModules) {
57
- requiringModules?.forEach((requiredModule) => {
58
- const isLocalFile = existsSync(requiredModule) || existsSync(`${requiredModule}.js`);
59
- const modulePath = isLocalFile ? resolve(requiredModule) : requiredModule;
60
- require(modulePath);
61
- });
37
+ if (requiringModules) {
38
+ requiringModules.forEach((requiredModule) => {
39
+ const isLocalFile = existsSync(requiredModule) || existsSync(`${requiredModule}.js`);
40
+ if (isLocalFile) {
41
+ requiredModule = resolve(requiredModule);
42
+ }
43
+ require(requiredModule);
44
+ });
45
+ }
62
46
  }
63
47
 
64
48
  /**
65
- * Initializes CodeceptJS in a specific directory.
66
- * @param {string} dir - Directory path.
49
+ * Initialize CodeceptJS at specific directory.
50
+ * If async initialization is required, pass callback as second parameter.
51
+ *
52
+ * @param {string} dir
67
53
  */
68
54
  init(dir) {
69
55
  this.initGlobals(dir);
56
+ // initializing listeners
70
57
  container.create(this.config, this.opts);
71
58
  this.runHooks();
72
59
  }
73
60
 
74
61
  /**
75
- * Initializes global variables.
76
- * @param {string} dir - Directory path.
62
+ * Creates global variables
63
+ *
64
+ * @param {string} dir
77
65
  */
78
66
  initGlobals(dir) {
79
67
  global.codecept_dir = dir;
80
- global.output_dir = resolve(dir, this.config.output);
68
+ global.output_dir = fsPath.resolve(dir, this.config.output);
81
69
 
82
70
  if (this.config.emptyOutputFolder) emptyFolder(global.output_dir);
83
71
 
84
72
  if (!this.config.noGlobals) {
85
- this.initGlobalHelpers();
73
+ global.Helper = global.codecept_helper = require('@codeceptjs/helper');
74
+ global.actor = global.codecept_actor = require('./actor');
75
+ global.pause = require('./pause');
76
+ global.within = require('./within');
77
+ global.session = require('./session');
78
+ global.DataTable = require('./data/table');
79
+ global.locate = locator => require('./locator').build(locator);
80
+ global.inject = container.support;
81
+ global.share = container.share;
82
+ global.secret = require('./secret').secret;
83
+ global.codecept_debug = output.debug;
84
+ global.codeceptjs = require('./index'); // load all objects
85
+
86
+ // BDD
87
+ const stepDefinitions = require('./interfaces/bdd');
88
+ global.Given = stepDefinitions.Given;
89
+ global.When = stepDefinitions.When;
90
+ global.Then = stepDefinitions.Then;
91
+ global.DefineParameterType = stepDefinitions.defineParameterType;
92
+
93
+ // debug mode
94
+ global.debugMode = false;
95
+
96
+ // mask sensitive data
97
+ global.maskSensitiveData = this.config.maskSensitiveData || false;
86
98
  }
87
99
  }
88
100
 
89
101
  /**
90
- * Initializes global helpers and other CodeceptJS features.
91
- */
92
- initGlobalHelpers() {
93
- global.Helper = global.codecept_helper = index.generated;
94
- global.actor = global.codecept_actor = actor;
95
- global.pause = pause;
96
- global.within = within;
97
- global.session = session;
98
- global.DataTable = data;
99
- global.locate = (locator) => new Locator(locator);
100
- global.inject = container.support;
101
- global.share = container.share;
102
- global.secret = secret;
103
- global.codecept_debug = output.debug;
104
- global.codeceptjs = index;
105
-
106
- // BDD
107
- global.Given = stepDefinitions.Given;
108
- global.When = stepDefinitions.When;
109
- global.Then = stepDefinitions.Then;
110
- global.DefineParameterType = stepDefinitions.defineParameterType;
111
- global.debugMode = false;
112
- }
113
-
114
- /**
115
- * Runs all hooks, including custom and default.
102
+ * Executes hooks.
116
103
  */
117
104
  runHooks() {
118
- const listeners = [
119
- listener,
120
- listenerArtifacts,
121
- listenerConfig,
122
- listenerHelpers,
123
- listenerRetry,
124
- listenerTimeout,
125
- listenerExit,
126
- ];
127
-
128
- listeners.forEach(runHook);
129
-
130
- // Run custom hooks
131
- this.config.hooks.forEach(runHook);
105
+ // default hooks
106
+ runHook(require('./listener/steps'));
107
+ runHook(require('./listener/artifacts'));
108
+ runHook(require('./listener/config'));
109
+ runHook(require('./listener/helpers'));
110
+ runHook(require('./listener/retry'));
111
+ runHook(require('./listener/timeout'));
112
+ runHook(require('./listener/exit'));
113
+
114
+ // custom hooks (previous iteration of plugins)
115
+ this.config.hooks.forEach(hook => runHook(hook));
132
116
  }
133
117
 
134
118
  /**
135
- * Executes the bootstrap process.
119
+ * Executes bootstrap.
120
+ *
136
121
  */
137
122
  async bootstrap() {
138
123
  return runHook(this.config.bootstrap, 'bootstrap');
139
124
  }
140
125
 
141
126
  /**
142
- * Executes the teardown process.
127
+ * Executes teardown.
128
+
143
129
  */
144
130
  async teardown() {
145
131
  return runHook(this.config.teardown, 'teardown');
146
132
  }
147
133
 
148
134
  /**
149
- * Loads test files based on the given pattern or config.
150
- * @param {string} [pattern] - Optional pattern for loading tests.
135
+ * Loads tests by pattern or by config.tests
136
+ *
137
+ * @param {string} [pattern]
151
138
  */
152
139
  loadTests(pattern) {
153
- const patterns = this.getTestPatterns(pattern);
154
- const options = { cwd: global.codecept_dir };
155
-
156
- patterns.forEach((p) => {
157
- glob.sync(p, options).forEach((file) => {
158
- if (!file.includes('node_modules')) {
159
- const fullPath = isAbsolute(file) ? file : join(global.codecept_dir, file);
160
- const resolvedFile = resolve(fullPath);
161
-
162
- if (!this.testFiles.includes(resolvedFile)) {
163
- this.testFiles.push(resolvedFile);
164
- }
140
+ const options = {
141
+ cwd: global.codecept_dir,
142
+ };
143
+
144
+ let patterns = [pattern];
145
+ if (!pattern) {
146
+ patterns = [];
147
+
148
+ // If the user wants to test a specific set of test files as an array or string.
149
+ if (this.config.tests && !this.opts.features) {
150
+ if (Array.isArray(this.config.tests)) {
151
+ patterns.push(...this.config.tests);
152
+ } else {
153
+ patterns.push(this.config.tests);
165
154
  }
166
- });
167
- });
168
- }
169
-
170
- /**
171
- * Gets test patterns based on config and options.
172
- * @param {string} [pattern] - Test pattern to match.
173
- * @returns {string[]} - Array of test patterns.
174
- */
175
- getTestPatterns(pattern) {
176
- if (pattern) return [pattern];
177
-
178
- const patterns = [];
179
- const { tests, gherkin } = this.config;
155
+ }
180
156
 
181
- if (tests && !this.opts.features) {
182
- patterns.push(...(Array.isArray(tests) ? tests : [tests]));
157
+ if (this.config.gherkin.features && !this.opts.tests) {
158
+ if (Array.isArray(this.config.gherkin.features)) {
159
+ this.config.gherkin.features.forEach(feature => {
160
+ patterns.push(feature);
161
+ });
162
+ } else {
163
+ patterns.push(this.config.gherkin.features);
164
+ }
165
+ }
183
166
  }
184
167
 
185
- if (gherkin?.features && !this.opts.tests) {
186
- patterns.push(...(Array.isArray(gherkin.features) ? gherkin.features : [gherkin.features]));
168
+ for (pattern of patterns) {
169
+ glob.sync(pattern, options).forEach((file) => {
170
+ if (file.includes('node_modules')) return;
171
+ if (!fsPath.isAbsolute(file)) {
172
+ file = fsPath.join(global.codecept_dir, file);
173
+ }
174
+ if (!this.testFiles.includes(fsPath.resolve(file))) {
175
+ this.testFiles.push(fsPath.resolve(file));
176
+ }
177
+ });
187
178
  }
188
-
189
- return patterns;
190
179
  }
191
180
 
192
181
  /**
193
- * Runs tests either specific to a file or all loaded tests.
194
- * @param {string} [test] - Test file to run.
182
+ * Run a specific test or all loaded tests.
183
+ *
184
+ * @param {string} [test]
195
185
  * @returns {Promise<void>}
196
186
  */
197
187
  async run(test) {
198
- const mocha = container.mocha();
199
- mocha.files = this.testFiles;
200
-
201
- if (test) {
202
- const testPath = isAbsolute(test) ? test : join(global.codecept_dir, test);
203
- mocha.files = mocha.files.filter((t) => resolve(t) === resolve(testPath));
204
- }
205
-
206
188
  return new Promise((resolve, reject) => {
189
+ const mocha = container.mocha();
190
+ mocha.files = this.testFiles;
191
+ if (test) {
192
+ if (!fsPath.isAbsolute(test)) {
193
+ test = fsPath.join(global.codecept_dir, test);
194
+ }
195
+ mocha.files = mocha.files.filter(t => fsPath.basename(t, '.js') === test || t === test);
196
+ }
197
+ const done = () => {
198
+ event.emit(event.all.result, this);
199
+ event.emit(event.all.after, this);
200
+ resolve();
201
+ };
202
+
207
203
  try {
208
204
  event.emit(event.all.before, this);
209
- mocha.run(() => {
210
- event.emit(event.all.result, this);
211
- event.emit(event.all.after, this);
212
- resolve();
213
- });
214
- } catch (error) {
215
- output.output.error(error.stack);
216
- reject(error);
205
+ mocha.run(() => done());
206
+ } catch (e) {
207
+ output.error(e.stack);
208
+ reject(e);
217
209
  }
218
210
  });
219
211
  }
220
- }
221
212
 
222
- /**
223
- * Retrieves the version from package.json.
224
- * @returns {string} - The version of the package.
225
- */
226
- export function version() {
227
- return JSON.parse(readFileSync(resolve(__dirname, '../package.json'), 'utf8')).version;
213
+ static version() {
214
+ return JSON.parse(readFileSync(`${__dirname}/../package.json`, 'utf8')).version;
215
+ }
228
216
  }
217
+
218
+ module.exports = Codecept;
package/lib/colorUtils.js CHANGED
@@ -189,7 +189,7 @@ function convertHexColorToRgba(hex) {
189
189
  *
190
190
  * @param {string} color Color as a string, i.e. rgb(85,0,0)
191
191
  */
192
- export function convertColorToRGBA(color) {
192
+ function convertColorToRGBA(color) {
193
193
  const cstr = `${color}`.toLowerCase().trim() || '';
194
194
 
195
195
  if (!/^rgba?\(.+?\)$/.test(cstr)) {
@@ -221,7 +221,7 @@ export function convertColorToRGBA(color) {
221
221
  *
222
222
  * @param {string} prop CSS Property name
223
223
  */
224
- export function isColorProperty(prop) {
224
+ function isColorProperty(prop) {
225
225
  return [
226
226
  'color',
227
227
  'background',
@@ -248,7 +248,7 @@ export function isColorProperty(prop) {
248
248
  ].indexOf(prop) > -1;
249
249
  }
250
250
 
251
- export default {
251
+ module.exports = {
252
252
  isColorProperty,
253
253
  convertColorToRGBA,
254
254
  convertColorNameToHex,
@@ -1,70 +1,76 @@
1
- import colors from 'chalk';
2
- import fs from 'fs';
3
- import inquirer from 'inquirer';
4
- import mkdirp from 'mkdirp';
5
- import path from 'path';
6
- import util from 'util';
7
- import * as outputLib from '../output.js';
8
- import { fileExists } from '../utils.js';
9
- import { getTestRoot } from './utils.js';
1
+ const colors = require('chalk')
2
+ const fs = require('fs')
3
+ const inquirer = require('inquirer')
4
+ const mkdirp = require('mkdirp')
5
+ const path = require('path')
6
+ const util = require('util')
10
7
 
11
- export default function (initPath) {
12
- const testsPath = getTestRoot(initPath);
8
+ const { print, success, error } = require('../output')
9
+ const { fileExists } = require('../utils')
10
+ const { getTestRoot } = require('./utils')
13
11
 
14
- outputLib.print();
15
- outputLib.print(` Welcome to ${colors.magenta.bold('CodeceptJS')} configuration migration tool`);
16
- outputLib.print(` It will help you switch from ${colors.cyan.bold('.json')} to ${colors.magenta.bold('.js')} config format at ease`);
17
- outputLib.print();
12
+ module.exports = function (initPath) {
13
+ const testsPath = getTestRoot(initPath)
14
+
15
+ print()
16
+ print(` Welcome to ${colors.magenta.bold('CodeceptJS')} configuration migration tool`)
17
+ print(
18
+ ` It will help you switch from ${colors.cyan.bold('.json')} to ${colors.magenta.bold('.js')} config format at ease`,
19
+ )
20
+ print()
18
21
 
19
22
  if (!path) {
20
- outputLib.print('No config file is specified.');
21
- outputLib.print(`Test root is assumed to be ${colors.yellow.bold(testsPath)}`);
22
- outputLib.print('----------------------------------');
23
+ print('No config file is specified.')
24
+ print(`Test root is assumed to be ${colors.yellow.bold(testsPath)}`)
25
+ print('----------------------------------')
23
26
  } else {
24
- outputLib.print(`Migrating ${colors.magenta.bold('.js')} config to ${colors.bold(testsPath)}`);
27
+ print(`Migrating ${colors.magenta.bold('.js')} config to ${colors.bold(testsPath)}`)
25
28
  }
26
29
 
27
30
  if (!fileExists(testsPath)) {
28
- outputLib.print(`Directory ${testsPath} does not exist, creating...`);
29
- mkdirp.sync(testsPath);
31
+ print(`Directory ${testsPath} does not exist, creating...`)
32
+ mkdirp.sync(testsPath)
30
33
  }
31
34
 
32
- const configFile = path.join(testsPath, 'codecept.conf.js');
35
+ const configFile = path.join(testsPath, 'codecept.conf.js')
33
36
  if (fileExists(configFile)) {
34
- outputLib.output.output.error(`Config is already created at ${configFile}`);
35
- return;
37
+ error(`Config is already created at ${configFile}`)
38
+ return
36
39
  }
37
40
 
38
- inquirer.prompt([{
39
- name: 'configFile',
40
- type: 'confirm',
41
- message: `Would you like to switch from ${colors.cyan.bold('.json')} to ${colors.magenta.bold('.js')} config format?`,
42
- default: true,
43
- },
44
- {
45
- name: 'delete',
46
- type: 'confirm',
47
- message: `Would you like to delete ${colors.cyan.bold('.json')} config format afterwards?`,
48
- default: true,
49
- },
50
- ]).then((result) => {
51
- if (result.configFile) {
52
- const jsonConfigFile = path.join(testsPath, 'codecept.js');
53
- const config = JSON.parse(fs.readFileSync(jsonConfigFile, 'utf8'));
54
- config.name = testsPath.split(path.sep).pop();
41
+ inquirer
42
+ .prompt([
43
+ {
44
+ name: 'configFile',
45
+ type: 'confirm',
46
+ message: `Would you like to switch from ${colors.cyan.bold('.json')} to ${colors.magenta.bold('.js')} config format?`,
47
+ default: true,
48
+ },
49
+ {
50
+ name: 'delete',
51
+ type: 'confirm',
52
+ message: `Would you like to delete ${colors.cyan.bold('.json')} config format afterwards?`,
53
+ default: true,
54
+ },
55
+ ])
56
+ .then((result) => {
57
+ if (result.configFile) {
58
+ const jsonConfigFile = path.join(testsPath, 'codecept.js')
59
+ const config = JSON.parse(fs.readFileSync(jsonConfigFile, 'utf8'))
60
+ config.name = testsPath.split(path.sep).pop()
55
61
 
56
- const finish = () => {
57
- fs.writeFileSync(configFile, `exports.config = ${util.inspect(config, false, 4, false)}`, 'utf-8');
58
- outputLib.output.success(`Config is successfully migrated at ${configFile}`);
62
+ const finish = () => {
63
+ fs.writeFileSync(configFile, `exports.config = ${util.inspect(config, false, 4, false)}`, 'utf-8')
64
+ success(`Config is successfully migrated at ${configFile}`)
59
65
 
60
- if (result.delete) {
61
- if (fileExists(jsonConfigFile)) {
62
- fs.unlinkSync(jsonConfigFile);
63
- outputLib.output.success('JSON config file is deleted!');
66
+ if (result.delete) {
67
+ if (fileExists(jsonConfigFile)) {
68
+ fs.unlinkSync(jsonConfigFile)
69
+ success('JSON config file is deleted!')
70
+ }
64
71
  }
65
72
  }
66
- };
67
- finish();
68
- }
69
- });
73
+ finish()
74
+ }
75
+ })
70
76
  }