@zohodesk/testinglibrary 0.1.8-exp.12 → 0.1.8-exp.14

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.
@@ -4,10 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getEnvConfigFilePath = getEnvConfigFilePath;
7
+ exports.getReportFileName = getReportFileName;
7
8
  exports.getUATFileName = getUATFileName;
8
9
  function getUATFileName() {
9
10
  return 'uat.config.js';
10
11
  }
11
12
  function getEnvConfigFilePath() {
12
13
  return `uat/env-config.json`;
14
+ }
15
+ function getReportFileName() {
16
+ return `test-summary.json`;
13
17
  }
@@ -14,6 +14,9 @@ var _readConfigFile = require("../readConfigFile");
14
14
  var _bddFramework = require("../../../bdd-framework");
15
15
  var _logger = require("../../../utils/logger");
16
16
  var _browserTypes = require("../constants/browserTypes");
17
+ var _fs = require("fs");
18
+ var _configFileNameProvider = require("../helpers/configFileNameProvider");
19
+ var _fileUtils = require("../../../utils/fileUtils");
17
20
  /**
18
21
  ** Playwright project configuration
19
22
  * @returns {import('@playwright/test').Project}
@@ -91,8 +94,8 @@ function getBrowserConfig({
91
94
  }
92
95
 
93
96
  /**
94
- *
95
- * @param {*} param0
97
+ *
98
+ * @param {*} param0
96
99
  * @returns {import('@playwright/test').Project[]}
97
100
  */
98
101
  function getProjects({
@@ -122,11 +125,31 @@ function getBrowsersList(browserFromArgs) {
122
125
  }
123
126
  return [];
124
127
  }
128
+ function getPathsForFeatureFiles(cwd) {
129
+ console.log('isRerun cases', process.env.isRerunFailedCases);
130
+ if (process.env.isRerunFailedCases) {
131
+ let {
132
+ reportPath
133
+ } = (0, _readConfigFile.generateConfigFromFile)();
134
+ const testSummary = (0, _fileUtils.readFileContents)(_path.default.join(reportPath, './', (0, _configFileNameProvider.getReportFileName)()));
135
+ if (testSummary !== null) {
136
+ const {
137
+ failed = []
138
+ } = JSON.parse(testSummary);
139
+ const casesToRun = failed.map(filePath => _path.default.join(cwd, 'uat', filePath.replace(/\.spec\.js$|\.js$/, '')));
140
+ return casesToRun;
141
+ } else {
142
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, `Unable to read test summary from the ${reportPath}. Verify If File Exists in the path`);
143
+ _logger.Logger.log(_logger.Logger.INFO_TYPE, 'Going to run all test cases');
144
+ }
145
+ }
146
+ return [_path.default.join(cwd, 'uat', '**', '*.feature')];
147
+ }
125
148
  function getTestDir(bddMode, cwd, {
126
149
  stepDefinitionsFolder
127
150
  }) {
128
151
  return bddMode ? (0, _bddFramework.defineBddConfig)({
129
- paths: [_path.default.join(cwd, 'uat', '**', '*.feature')],
152
+ paths: getPathsForFeatureFiles(cwd),
130
153
  import: [_path.default.join(cwd, 'uat', '**', stepDefinitionsFolder, '*.spec.js')],
131
154
  featuresRoot: _path.default.join(cwd, 'uat'),
132
155
  outputDir: _path.default.join(cwd, 'uat', '.features-gen'),
@@ -10,6 +10,7 @@ var _readline = _interopRequireDefault(require("readline"));
10
10
  var _fileUtils = require("../../../utils/fileUtils");
11
11
  var _readConfigFile = require("../readConfigFile");
12
12
  var _logger = require("../../../utils/logger");
13
+ var _configFileNameProvider = require("../helpers/configFileNameProvider");
13
14
  class JSONSummaryReporter {
14
15
  constructor() {
15
16
  this.durationInMS = -1;
@@ -43,7 +44,7 @@ class JSONSummaryReporter {
43
44
  }
44
45
  }
45
46
  // This will publish the file name + line number test begins on
46
- const z = `${fileName[0]}:${test.location.line}:${test.location.column}`;
47
+ const z = `${fileName[0]}`;
47
48
  // Using the t variable in the push will push a full test name + test description
48
49
  const t = title.join(' > ');
49
50
  // Set the status
@@ -93,7 +94,7 @@ class JSONSummaryReporter {
93
94
  let {
94
95
  reportPath
95
96
  } = (0, _readConfigFile.generateConfigFromFile)();
96
- (0, _fileUtils.writeFileContents)(_path.default.join(reportPath, './', 'test-summary.json'), JSON.stringify(this, null, ' '));
97
+ (0, _fileUtils.writeFileContents)(_path.default.join(reportPath, './', (0, _configFileNameProvider.getReportFileName)()), JSON.stringify(this, null, ' '));
97
98
  }
98
99
  onExit() {
99
100
  const shouldClearLastLine = this._open !== 'always' || this._open !== 'on-failure';
@@ -51,7 +51,10 @@ function runPreprocessing(tagArgs, configPath) {
51
51
  }
52
52
  return new Promise((resolve, reject) => {
53
53
  const childProcessForPreprocessing = (0, _child_process.spawn)(beforeCommand, beforeArgs, {
54
- stdio: 'inherit'
54
+ stdio: 'inherit',
55
+ env: {
56
+ ...process.env
57
+ }
55
58
  });
56
59
  childProcessForPreprocessing.on('error', data => {
57
60
  _logger.Logger.log(_logger.Logger.FAILURE_TYPE, data);
@@ -70,7 +73,10 @@ function runPreprocessing(tagArgs, configPath) {
70
73
  function runPlaywright(command, args) {
71
74
  return new Promise((resolve, reject) => {
72
75
  const childProcessForRunningPlaywright = (0, _child_process.spawn)(command, args, {
73
- stdio: 'inherit'
76
+ stdio: 'inherit',
77
+ env: {
78
+ ...process.env
79
+ }
74
80
  });
75
81
  childProcessForRunningPlaywright.on('error', error => {
76
82
  _logger.Logger.log(_logger.Logger.FAILURE_TYPE, error);
@@ -95,8 +101,6 @@ function runPlaywright(command, args) {
95
101
  }
96
102
  function main() {
97
103
  const userArgsObject = parseUserArgs();
98
- // eslint-disable-next-line
99
-
100
104
  const {
101
105
  debug,
102
106
  mode = 'dev',
@@ -120,4 +124,5 @@ function main() {
120
124
  process.exit();
121
125
  });
122
126
  }
127
+ function rerunFailedCases() {}
123
128
  var _default = exports.default = main;
package/build/lib/cli.js CHANGED
@@ -20,6 +20,13 @@ switch (option) {
20
20
  //createJestRunner();
21
21
  break;
22
22
  }
23
+ case 're-run-failed':
24
+ {
25
+ _logger.Logger.log(_logger.Logger.SUCCESS_TYPE, 'Running Failed Tests..');
26
+ process.env.isRerunFailedCases = true;
27
+ (0, _testRunner.default)();
28
+ break;
29
+ }
23
30
  case 'report':
24
31
  {
25
32
  // console.log('\x1b[36mGenerating Reports...\x1b[0m');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.1.8-exp.12",
3
+ "version": "0.1.8-exp.14",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {