codeceptjs 3.6.4 → 3.6.5-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/bin/codecept.js +84 -63
  2. package/lib/assert/empty.js +19 -19
  3. package/lib/assert/equal.js +32 -30
  4. package/lib/assert/error.js +14 -14
  5. package/lib/assert/include.js +42 -42
  6. package/lib/assert/throws.js +13 -11
  7. package/lib/assert/truth.js +17 -18
  8. package/lib/command/configMigrate.js +57 -52
  9. package/lib/command/definitions.js +88 -88
  10. package/lib/command/dryRun.js +65 -63
  11. package/lib/command/generate.js +191 -181
  12. package/lib/command/info.js +39 -37
  13. package/lib/command/init.js +289 -286
  14. package/lib/command/interactive.js +32 -32
  15. package/lib/command/list.js +26 -26
  16. package/lib/command/run-multiple.js +113 -93
  17. package/lib/command/run-rerun.js +22 -22
  18. package/lib/command/run-workers.js +63 -63
  19. package/lib/command/run.js +24 -26
  20. package/lib/command/utils.js +64 -63
  21. package/lib/data/context.js +60 -60
  22. package/lib/data/dataScenarioConfig.js +47 -47
  23. package/lib/data/dataTableArgument.js +29 -29
  24. package/lib/data/table.js +26 -20
  25. package/lib/helper/AI.js +67 -65
  26. package/lib/helper/ApiDataFactory.js +72 -69
  27. package/lib/helper/Appium.js +409 -379
  28. package/lib/helper/ExpectHelper.js +214 -248
  29. package/lib/helper/FileSystem.js +77 -78
  30. package/lib/helper/GraphQL.js +44 -43
  31. package/lib/helper/GraphQLDataFactory.js +49 -50
  32. package/lib/helper/JSONResponse.js +64 -62
  33. package/lib/helper/Mochawesome.js +28 -28
  34. package/lib/helper/MockServer.js +12 -12
  35. package/lib/helper/Nightmare.js +664 -572
  36. package/lib/helper/Playwright.js +1320 -1211
  37. package/lib/helper/Protractor.js +663 -629
  38. package/lib/helper/Puppeteer.js +1232 -1124
  39. package/lib/helper/REST.js +87 -72
  40. package/lib/helper/TestCafe.js +490 -491
  41. package/lib/helper/WebDriver.js +1294 -1156
  42. package/lib/interfaces/bdd.js +38 -51
  43. package/lib/interfaces/featureConfig.js +19 -19
  44. package/lib/interfaces/gherkin.js +122 -111
  45. package/lib/interfaces/scenarioConfig.js +29 -29
  46. package/lib/listener/artifacts.js +9 -9
  47. package/lib/listener/config.js +24 -23
  48. package/lib/listener/exit.js +12 -12
  49. package/lib/listener/helpers.js +42 -42
  50. package/lib/listener/mocha.js +11 -11
  51. package/lib/listener/retry.js +32 -30
  52. package/lib/listener/steps.js +50 -51
  53. package/lib/listener/timeout.js +53 -53
  54. package/lib/plugin/allure.js +14 -14
  55. package/lib/plugin/autoDelay.js +29 -36
  56. package/lib/plugin/autoLogin.js +70 -66
  57. package/lib/plugin/commentStep.js +18 -18
  58. package/lib/plugin/coverage.js +92 -77
  59. package/lib/plugin/customLocator.js +20 -19
  60. package/lib/plugin/debugErrors.js +24 -24
  61. package/lib/plugin/eachElement.js +37 -37
  62. package/lib/plugin/fakerTransform.js +6 -6
  63. package/lib/plugin/heal.js +66 -63
  64. package/lib/plugin/pauseOnFail.js +10 -10
  65. package/lib/plugin/retryFailedStep.js +31 -38
  66. package/lib/plugin/retryTo.js +28 -28
  67. package/lib/plugin/screenshotOnFail.js +107 -86
  68. package/lib/plugin/selenoid.js +131 -117
  69. package/lib/plugin/standardActingHelpers.js +2 -8
  70. package/lib/plugin/stepByStepReport.js +102 -92
  71. package/lib/plugin/stepTimeout.js +23 -22
  72. package/lib/plugin/subtitles.js +34 -34
  73. package/lib/plugin/tryTo.js +39 -29
  74. package/lib/plugin/wdio.js +77 -72
  75. package/lib/template/heal.js +11 -14
  76. package/package.json +4 -2
  77. package/translations/de-DE.js +1 -1
  78. package/translations/fr-FR.js +1 -1
  79. package/translations/index.js +9 -9
  80. package/translations/it-IT.js +1 -1
  81. package/translations/ja-JP.js +1 -1
  82. package/translations/pl-PL.js +1 -1
  83. package/translations/pt-BR.js +1 -1
  84. package/translations/ru-RU.js +1 -1
  85. package/translations/zh-CN.js +1 -1
  86. package/translations/zh-TW.js +1 -1
  87. package/typings/promiseBasedTypes.d.ts +238 -0
  88. package/typings/types.d.ts +32 -0
@@ -1,89 +1,89 @@
1
1
  // For Node version >=10.5.0, have to use experimental flag
2
- const { tryOrDefault } = require('../utils');
3
- const output = require('../output');
4
- const store = require('../store');
5
- const event = require('../event');
6
- const Workers = require('../workers');
2
+ const { tryOrDefault } = require('../utils')
3
+ const output = require('../output')
4
+ const store = require('../store')
5
+ const event = require('../event')
6
+ const Workers = require('../workers')
7
7
 
8
8
  module.exports = async function (workerCount, selectedRuns, options) {
9
- process.env.profile = options.profile;
10
-
11
- const suiteArr = [];
12
- const passedTestArr = [];
13
- const failedTestArr = [];
14
- const skippedTestArr = [];
15
- const stepArr = [];
16
-
17
- const { config: testConfig, override = '' } = options;
18
- const overrideConfigs = tryOrDefault(() => JSON.parse(override), {});
19
- const by = options.suites ? 'suite' : 'test';
20
- delete options.parent;
9
+ process.env.profile = options.profile
10
+
11
+ const suiteArr = []
12
+ const passedTestArr = []
13
+ const failedTestArr = []
14
+ const skippedTestArr = []
15
+ const stepArr = []
16
+
17
+ const { config: testConfig, override = '' } = options
18
+ const overrideConfigs = tryOrDefault(() => JSON.parse(override), {})
19
+ const by = options.suites ? 'suite' : 'test'
20
+ delete options.parent
21
21
  const config = {
22
22
  by,
23
23
  testConfig,
24
24
  options,
25
25
  selectedRuns,
26
- };
26
+ }
27
27
 
28
- const numberOfWorkers = parseInt(workerCount, 10);
28
+ const numberOfWorkers = parseInt(workerCount, 10)
29
29
 
30
- output.print(`CodeceptJS v${require('../codecept').version()} ${output.standWithUkraine()}`);
31
- output.print(`Running tests in ${output.styles.bold(numberOfWorkers)} workers...`);
32
- output.print();
30
+ output.print(`CodeceptJS v${require('../codecept').version()} ${output.standWithUkraine()}`)
31
+ output.print(`Running tests in ${output.styles.bold(numberOfWorkers)} workers...`)
32
+ output.print()
33
33
 
34
- const workers = new Workers(numberOfWorkers, config);
35
- workers.overrideConfig(overrideConfigs);
34
+ const workers = new Workers(numberOfWorkers, config)
35
+ workers.overrideConfig(overrideConfigs)
36
36
 
37
37
  workers.on(event.suite.before, (suite) => {
38
- suiteArr.push(suite);
39
- });
38
+ suiteArr.push(suite)
39
+ })
40
40
 
41
41
  workers.on(event.step.passed, (step) => {
42
- stepArr.push(step);
43
- });
42
+ stepArr.push(step)
43
+ })
44
44
 
45
45
  workers.on(event.step.failed, (step) => {
46
- stepArr.push(step);
47
- });
46
+ stepArr.push(step)
47
+ })
48
48
 
49
49
  workers.on(event.test.failed, (test) => {
50
- failedTestArr.push(test);
51
- output.test.failed(test);
52
- });
50
+ failedTestArr.push(test)
51
+ output.test.failed(test)
52
+ })
53
53
 
54
54
  workers.on(event.test.passed, (test) => {
55
- passedTestArr.push(test);
56
- output.test.passed(test);
57
- });
55
+ passedTestArr.push(test)
56
+ output.test.passed(test)
57
+ })
58
58
 
59
59
  workers.on(event.test.skipped, (test) => {
60
- skippedTestArr.push(test);
61
- output.test.skipped(test);
62
- });
60
+ skippedTestArr.push(test)
61
+ output.test.skipped(test)
62
+ })
63
63
 
64
64
  workers.on(event.all.result, () => {
65
65
  // expose test stats after all workers finished their execution
66
66
  function addStepsToTest(test, stepArr) {
67
- stepArr.test.steps.forEach(step => {
67
+ stepArr.test.steps.forEach((step) => {
68
68
  if (test.steps.length === 0) {
69
- test.steps.push(step);
69
+ test.steps.push(step)
70
70
  }
71
- });
71
+ })
72
72
  }
73
73
 
74
- stepArr.forEach(step => {
75
- passedTestArr.forEach(test => {
74
+ stepArr.forEach((step) => {
75
+ passedTestArr.forEach((test) => {
76
76
  if (step.test.title === test.title) {
77
- addStepsToTest(test, step);
77
+ addStepsToTest(test, step)
78
78
  }
79
- });
79
+ })
80
80
 
81
- failedTestArr.forEach(test => {
81
+ failedTestArr.forEach((test) => {
82
82
  if (step.test.title === test.title) {
83
- addStepsToTest(test, step);
83
+ addStepsToTest(test, step)
84
84
  }
85
- });
86
- });
85
+ })
86
+ })
87
87
 
88
88
  event.dispatcher.emit(event.workers.result, {
89
89
  suites: suiteArr,
@@ -92,24 +92,24 @@ module.exports = async function (workerCount, selectedRuns, options) {
92
92
  failed: failedTestArr,
93
93
  skipped: skippedTestArr,
94
94
  },
95
- });
96
- workers.printResults();
97
- });
95
+ })
96
+ workers.printResults()
97
+ })
98
98
 
99
99
  try {
100
- if (options.verbose || options.debug) store.debugMode = true;
100
+ if (options.verbose || options.debug) store.debugMode = true
101
101
 
102
102
  if (options.verbose) {
103
- global.debugMode = true;
104
- const { getMachineInfo } = require('./info');
105
- await getMachineInfo();
103
+ global.debugMode = true
104
+ const { getMachineInfo } = require('./info')
105
+ await getMachineInfo()
106
106
  }
107
- await workers.bootstrapAll();
108
- await workers.run();
107
+ await workers.bootstrapAll()
108
+ await workers.run()
109
109
  } catch (err) {
110
- output.error(err);
111
- process.exit(1);
110
+ output.error(err)
111
+ process.exit(1)
112
112
  } finally {
113
- await workers.teardownAll();
113
+ await workers.teardownAll()
114
114
  }
115
- };
115
+ }
@@ -1,48 +1,46 @@
1
- const {
2
- getConfig, printError, getTestRoot, createOutputDir,
3
- } = require('./utils');
4
- const Config = require('../config');
5
- const store = require('../store');
6
- const Codecept = require('../codecept');
1
+ const { getConfig, printError, getTestRoot, createOutputDir } = require('./utils')
2
+ const Config = require('../config')
3
+ const store = require('../store')
4
+ const Codecept = require('../codecept')
7
5
 
8
6
  module.exports = async function (test, options) {
9
7
  // registering options globally to use in config
10
8
  // Backward compatibility for --profile
11
9
  // TODO: remove in CodeceptJS 4
12
- process.profile = options.profile;
10
+ process.profile = options.profile
13
11
 
14
12
  if (options.profile) {
15
- process.env.profile = options.profile;
13
+ process.env.profile = options.profile
16
14
  }
17
- if (options.verbose || options.debug) store.debugMode = true;
15
+ if (options.verbose || options.debug) store.debugMode = true
18
16
 
19
- const configFile = options.config;
17
+ const configFile = options.config
20
18
 
21
- let config = getConfig(configFile);
19
+ let config = getConfig(configFile)
22
20
  if (options.override) {
23
- config = Config.append(JSON.parse(options.override));
21
+ config = Config.append(JSON.parse(options.override))
24
22
  }
25
- const testRoot = getTestRoot(configFile);
26
- createOutputDir(config, testRoot);
23
+ const testRoot = getTestRoot(configFile)
24
+ createOutputDir(config, testRoot)
27
25
 
28
- const codecept = new Codecept(config, options);
26
+ const codecept = new Codecept(config, options)
29
27
 
30
28
  try {
31
- codecept.init(testRoot);
32
- await codecept.bootstrap();
33
- codecept.loadTests(test);
29
+ codecept.init(testRoot)
30
+ await codecept.bootstrap()
31
+ codecept.loadTests(test)
34
32
 
35
33
  if (options.verbose) {
36
- global.debugMode = true;
37
- const { getMachineInfo } = require('./info');
38
- await getMachineInfo();
34
+ global.debugMode = true
35
+ const { getMachineInfo } = require('./info')
36
+ await getMachineInfo()
39
37
  }
40
38
 
41
- await codecept.run();
39
+ await codecept.run()
42
40
  } catch (err) {
43
- printError(err);
44
- process.exitCode = 1;
41
+ printError(err)
42
+ process.exitCode = 1
45
43
  } finally {
46
- await codecept.teardown();
44
+ await codecept.teardown()
47
45
  }
48
- };
46
+ }
@@ -1,117 +1,118 @@
1
- const fs = require('fs');
2
- const path = require('path');
3
- const util = require('util');
4
- const mkdirp = require('mkdirp');
1
+ const fs = require('fs')
2
+ const path = require('path')
3
+ const util = require('util')
4
+ const mkdirp = require('mkdirp')
5
5
 
6
- const output = require('../output');
7
- const { fileExists, beautify } = require('../utils');
6
+ const output = require('../output')
7
+ const { fileExists, beautify } = require('../utils')
8
8
 
9
9
  // alias to deep merge
10
- module.exports.deepMerge = require('../utils').deepMerge;
10
+ module.exports.deepMerge = require('../utils').deepMerge
11
11
 
12
12
  module.exports.getConfig = function (configFile) {
13
13
  try {
14
- return require('../config').load(configFile);
14
+ return require('../config').load(configFile)
15
15
  } catch (err) {
16
- fail(err.stack);
16
+ fail(err.stack)
17
17
  }
18
- };
18
+ }
19
19
 
20
20
  module.exports.readConfig = function (configFile) {
21
21
  try {
22
- const data = fs.readFileSync(configFile, 'utf8');
23
- return data;
22
+ const data = fs.readFileSync(configFile, 'utf8')
23
+ return data
24
24
  } catch (err) {
25
- output.error(err);
25
+ output.error(err)
26
26
  }
27
- };
27
+ }
28
28
 
29
29
  function getTestRoot(currentPath) {
30
- if (!currentPath) currentPath = '.';
31
- if (!path.isAbsolute(currentPath)) currentPath = path.join(process.cwd(), currentPath);
32
- currentPath = fs.lstatSync(currentPath).isDirectory() || !path.extname(currentPath) ? currentPath : path.dirname(currentPath);
33
- return currentPath;
30
+ if (!currentPath) currentPath = '.'
31
+ if (!path.isAbsolute(currentPath)) currentPath = path.join(process.cwd(), currentPath)
32
+ currentPath =
33
+ fs.lstatSync(currentPath).isDirectory() || !path.extname(currentPath) ? currentPath : path.dirname(currentPath)
34
+ return currentPath
34
35
  }
35
- module.exports.getTestRoot = getTestRoot;
36
+ module.exports.getTestRoot = getTestRoot
36
37
 
37
38
  function fail(msg) {
38
- output.error(msg);
39
- process.exit(1);
39
+ output.error(msg)
40
+ process.exit(1)
40
41
  }
41
42
 
42
- module.exports.fail = fail;
43
+ module.exports.fail = fail
43
44
 
44
45
  function updateConfig(testsPath, config, extension) {
45
- const configFile = path.join(testsPath, `codecept.conf.${extension}`);
46
+ const configFile = path.join(testsPath, `codecept.conf.${extension}`)
46
47
  if (!fileExists(configFile)) {
47
- const msg = `codecept.conf.${extension} config can\'t be updated automatically`;
48
- console.log();
49
- console.log(`${output.colors.bold.red(msg)}`);
50
- console.log(`${output.colors.bold.red('Please update it manually:')}`);
51
- console.log();
52
- console.log(config);
53
- console.log();
54
- return;
48
+ const msg = `codecept.conf.${extension} config can\'t be updated automatically`
49
+ console.log()
50
+ console.log(`${output.colors.bold.red(msg)}`)
51
+ console.log(`${output.colors.bold.red('Please update it manually:')}`)
52
+ console.log()
53
+ console.log(config)
54
+ console.log()
55
+ return
55
56
  }
56
- console.log(`${output.colors.yellow('Updating configuration file...')}`);
57
- return fs.writeFileSync(configFile, beautify(`exports.config = ${util.inspect(config, false, 4, false)}`), 'utf-8');
57
+ console.log(`${output.colors.yellow('Updating configuration file...')}`)
58
+ return fs.writeFileSync(configFile, beautify(`exports.config = ${util.inspect(config, false, 4, false)}`), 'utf-8')
58
59
  }
59
60
 
60
- module.exports.updateConfig = updateConfig;
61
+ module.exports.updateConfig = updateConfig
61
62
 
62
63
  function safeFileWrite(file, contents) {
63
64
  if (fileExists(file)) {
64
- output.error(`File ${file} already exist, skipping...`);
65
- return false;
65
+ output.error(`File ${file} already exist, skipping...`)
66
+ return false
66
67
  }
67
- fs.writeFileSync(file, contents);
68
- return true;
68
+ fs.writeFileSync(file, contents)
69
+ return true
69
70
  }
70
71
 
71
- module.exports.safeFileWrite = safeFileWrite;
72
+ module.exports.safeFileWrite = safeFileWrite
72
73
 
73
74
  module.exports.captureStream = (stream) => {
74
- let oldStream;
75
- let buffer = '';
75
+ let oldStream
76
+ let buffer = ''
76
77
 
77
78
  return {
78
79
  startCapture() {
79
- buffer = '';
80
- oldStream = stream.write.bind(stream);
81
- stream.write = chunk => (buffer += chunk);
80
+ buffer = ''
81
+ oldStream = stream.write.bind(stream)
82
+ stream.write = (chunk) => (buffer += chunk)
82
83
  },
83
84
  stopCapture() {
84
- if (oldStream !== undefined) stream.write = oldStream;
85
+ if (oldStream !== undefined) stream.write = oldStream
85
86
  },
86
87
  getData: () => buffer,
87
- };
88
- };
88
+ }
89
+ }
89
90
 
90
91
  module.exports.printError = (err) => {
91
- output.print('');
92
- output.error(err.message);
93
- output.print('');
94
- output.print(output.colors.grey(err.stack.replace(err.message, '')));
95
- };
92
+ output.print('')
93
+ output.error(err.message)
94
+ output.print('')
95
+ output.print(output.colors.grey(err.stack.replace(err.message, '')))
96
+ }
96
97
 
97
98
  module.exports.createOutputDir = (config, testRoot) => {
98
- let outputDir;
99
- if (path.isAbsolute(config.output)) outputDir = config.output;
100
- else outputDir = path.join(testRoot, config.output);
99
+ let outputDir
100
+ if (path.isAbsolute(config.output)) outputDir = config.output
101
+ else outputDir = path.join(testRoot, config.output)
101
102
 
102
103
  if (!fileExists(outputDir)) {
103
- output.print(`creating output directory: ${outputDir}`);
104
- mkdirp.sync(outputDir);
104
+ output.print(`creating output directory: ${outputDir}`)
105
+ mkdirp.sync(outputDir)
105
106
  }
106
- };
107
+ }
107
108
 
108
109
  module.exports.findConfigFile = (testsPath) => {
109
- const extensions = ['js', 'ts'];
110
+ const extensions = ['js', 'ts']
110
111
  for (const ext of extensions) {
111
- const configFile = path.join(testsPath, `codecept.conf.${ext}`);
112
+ const configFile = path.join(testsPath, `codecept.conf.${ext}`)
112
113
  if (fileExists(configFile)) {
113
- return configFile;
114
+ return configFile
114
115
  }
115
116
  }
116
- return null;
117
- };
117
+ return null
118
+ }
@@ -1,129 +1,129 @@
1
- const { isGenerator } = require('../utils');
2
- const DataTable = require('./table');
3
- const DataScenarioConfig = require('./dataScenarioConfig');
4
- const Secret = require('../secret');
1
+ const { isGenerator } = require('../utils')
2
+ const DataTable = require('./table')
3
+ const DataScenarioConfig = require('./dataScenarioConfig')
4
+ const Secret = require('../secret')
5
5
 
6
6
  module.exports = function (context) {
7
7
  context.Data = function (dataTable) {
8
- const data = detectDataType(dataTable);
8
+ const data = detectDataType(dataTable)
9
9
  return {
10
10
  Scenario(title, opts, fn) {
11
- const scenarios = [];
11
+ const scenarios = []
12
12
  if (typeof opts === 'function' && !fn) {
13
- fn = opts;
14
- opts = {};
13
+ fn = opts
14
+ opts = {}
15
15
  }
16
- opts.data = data.map(dataRow => dataRow.data);
16
+ opts.data = data.map((dataRow) => dataRow.data)
17
17
  data.forEach((dataRow) => {
18
- const dataTitle = replaceTitle(title, dataRow);
18
+ const dataTitle = replaceTitle(title, dataRow)
19
19
  if (dataRow.skip) {
20
- context.xScenario(dataTitle);
20
+ context.xScenario(dataTitle)
21
21
  } else {
22
- scenarios.push(context.Scenario(dataTitle, opts, fn)
23
- .inject({ current: dataRow.data }));
22
+ scenarios.push(context.Scenario(dataTitle, opts, fn).inject({ current: dataRow.data }))
24
23
  }
25
- });
26
- maskSecretInTitle(scenarios);
27
- return new DataScenarioConfig(scenarios);
24
+ })
25
+ maskSecretInTitle(scenarios)
26
+ return new DataScenarioConfig(scenarios)
28
27
  },
29
28
  only: {
30
29
  Scenario(title, opts, fn) {
31
- const scenarios = [];
30
+ const scenarios = []
32
31
  if (typeof opts === 'function' && !fn) {
33
- fn = opts;
34
- opts = {};
32
+ fn = opts
33
+ opts = {}
35
34
  }
36
- opts.data = data.map(dataRow => dataRow.data);
35
+ opts.data = data.map((dataRow) => dataRow.data)
37
36
  data.forEach((dataRow) => {
38
- const dataTitle = replaceTitle(title, dataRow);
37
+ const dataTitle = replaceTitle(title, dataRow)
39
38
  if (dataRow.skip) {
40
- context.xScenario(dataTitle);
39
+ context.xScenario(dataTitle)
41
40
  } else {
42
- scenarios.push(context.Scenario.only(dataTitle, opts, fn)
43
- .inject({ current: dataRow.data }));
41
+ scenarios.push(context.Scenario.only(dataTitle, opts, fn).inject({ current: dataRow.data }))
44
42
  }
45
- });
46
- maskSecretInTitle(scenarios);
47
- return new DataScenarioConfig(scenarios);
43
+ })
44
+ maskSecretInTitle(scenarios)
45
+ return new DataScenarioConfig(scenarios)
48
46
  },
49
47
  },
50
- };
51
- };
48
+ }
49
+ }
52
50
 
53
51
  context.xData = function (dataTable) {
54
- const data = detectDataType(dataTable);
52
+ const data = detectDataType(dataTable)
55
53
  return {
56
54
  Scenario: (title) => {
57
55
  data.forEach((dataRow) => {
58
- const dataTitle = replaceTitle(title, dataRow);
59
- context.xScenario(dataTitle);
60
- });
61
- return new DataScenarioConfig([]);
56
+ const dataTitle = replaceTitle(title, dataRow)
57
+ context.xScenario(dataTitle)
58
+ })
59
+ return new DataScenarioConfig([])
62
60
  },
63
- };
64
- };
65
- };
61
+ }
62
+ }
63
+ }
66
64
 
67
65
  function replaceTitle(title, dataRow) {
68
66
  if (typeof dataRow.data !== 'object') {
69
- return `${title} | {${JSON.stringify(dataRow.data)}}`;
67
+ return `${title} | {${JSON.stringify(dataRow.data)}}`
70
68
  }
71
69
 
72
70
  // if `dataRow` is object and has own `toString()` method,
73
71
  // it should be printed
74
- if (Object.prototype.toString.call(dataRow.data) === (Object()).toString()
75
- && dataRow.data.toString() !== (Object()).toString()) {
76
- return `${title} | ${dataRow.data}`;
72
+ if (
73
+ Object.prototype.toString.call(dataRow.data) === Object().toString() &&
74
+ dataRow.data.toString() !== Object().toString()
75
+ ) {
76
+ return `${title} | ${dataRow.data}`
77
77
  }
78
78
 
79
- return `${title} | ${JSON.stringify(dataRow.data)}`;
79
+ return `${title} | ${JSON.stringify(dataRow.data)}`
80
80
  }
81
81
 
82
82
  function isTableDataRow(row) {
83
- const has = Object.prototype.hasOwnProperty;
84
- return has.call(row, 'data') && has.call(row, 'skip');
83
+ const has = Object.prototype.hasOwnProperty
84
+ return has.call(row, 'data') && has.call(row, 'skip')
85
85
  }
86
86
 
87
87
  function detectDataType(dataTable) {
88
88
  if (dataTable instanceof DataTable) {
89
- return dataTable.rows;
89
+ return dataTable.rows
90
90
  }
91
91
 
92
92
  if (isGenerator(dataTable)) {
93
- const data = [];
93
+ const data = []
94
94
  for (const dataRow of dataTable()) {
95
95
  data.push({
96
96
  data: dataRow,
97
- });
97
+ })
98
98
  }
99
- return data;
99
+ return data
100
100
  }
101
101
  if (typeof dataTable === 'function') {
102
- return dataTable();
102
+ return dataTable()
103
103
  }
104
104
  if (Array.isArray(dataTable)) {
105
105
  return dataTable.map((item) => {
106
106
  if (isTableDataRow(item)) {
107
- return item;
107
+ return item
108
108
  }
109
109
  return {
110
110
  data: item,
111
111
  skip: false,
112
- };
113
- });
112
+ }
113
+ })
114
114
  }
115
115
 
116
- throw new Error('Invalid data type. Data accepts either: DataTable || generator || Array || function');
116
+ throw new Error('Invalid data type. Data accepts either: DataTable || generator || Array || function')
117
117
  }
118
118
 
119
119
  function maskSecretInTitle(scenarios) {
120
- scenarios.forEach(scenario => {
121
- const res = [];
120
+ scenarios.forEach((scenario) => {
121
+ const res = []
122
122
 
123
- scenario.test.title.split(',').forEach(item => {
124
- res.push(item.replace(/{"_secret":"(.*)"}/, '"*****"'));
125
- });
123
+ scenario.test.title.split(',').forEach((item) => {
124
+ res.push(item.replace(/{"_secret":"(.*)"}/, '"*****"'))
125
+ })
126
126
 
127
- scenario.test.title = res.join(',');
128
- });
127
+ scenario.test.title = res.join(',')
128
+ })
129
129
  }