@zohodesk/testinglibrary 0.3.1-experimental → 0.3.2-experimental

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.
package/README.md CHANGED
@@ -18,12 +18,10 @@
18
18
 
19
19
  ## Version History
20
20
 
21
- ### v0.2.8 - 18-09-2024
21
+ ### v0.2.8 - 26-09-2024
22
22
 
23
- #### Features
23
+ #### Feature
24
24
  - Added support for writing unitcases for framework implementations
25
- - Updated the configuration for `video` and `trace` to accept Playwright-specific values instead of boolean values.
26
25
 
27
- #### Deprecations
28
- - **Deprecated**: Passing `video` and `trace` as boolean (`true`/`false`) in project configuration.
29
- - **New Approach**: Use Playwright values for `video` and `trace` options, such as `'on'`, `'retain-on-failure'`, or `'off'`.
26
+ ### Bug fix
27
+ - Updated the custom-reported to include the errors in tests during the executions. It will help us avoid the stage passed without the actual test execution.
@@ -38,11 +38,12 @@ const testDir = (0, _configUtils.getTestDir)(bddMode, process.cwd(), {
38
38
  featureFilesFolder,
39
39
  stepDefinitionsFolder
40
40
  });
41
- let use = {
41
+ const testOptions = (0, _configUtils.getTestUseOptions)({
42
42
  trace,
43
43
  video,
44
+ viewport,
44
45
  testIdAttribute
45
- };
46
+ });
46
47
 
47
48
  /**
48
49
  * Playwright configuration object
@@ -65,7 +66,7 @@ function getPlaywrightConfig() {
65
66
  expect: {
66
67
  timeout: expectTimeout
67
68
  },
68
- use,
69
+ use: testOptions,
69
70
  projects: isAuthMode ? [{
70
71
  name: 'setup',
71
72
  testMatch: /.*\.setup\.js/,
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.getBrowsersList = getBrowsersList;
8
8
  exports.getProjects = getProjects;
9
9
  exports.getTestDir = getTestDir;
10
+ exports.getTestUseOptions = getTestUseOptions;
10
11
  var _test = require("@playwright/test");
11
12
  var _path = _interopRequireDefault(require("path"));
12
13
  var _readConfigFile = require("../readConfigFile");
@@ -154,4 +155,23 @@ function getTestDir(bddMode, cwd, {
154
155
  outputDir: _path.default.join(cwd, 'uat', '.features-gen'),
155
156
  publish: true
156
157
  }) : _path.default.join(cwd, 'uat');
158
+ }
159
+ function getTestUseOptions({
160
+ viewport,
161
+ trace,
162
+ video,
163
+ testIdAttribute
164
+ }) {
165
+ let defaultTestuseOptions = {
166
+ viewport,
167
+ testIdAttribute,
168
+ trace: trace ? 'on' : 'off',
169
+ video: video ? {
170
+ mode: 'on',
171
+ size: {
172
+ ...viewport
173
+ }
174
+ } : 'off'
175
+ };
176
+ return defaultTestuseOptions;
157
177
  }
@@ -18,6 +18,7 @@ class JSONSummaryReporter {
18
18
  this.skipped = [];
19
19
  this.failed = [];
20
20
  this.warned = [];
21
+ this.errored = [];
21
22
  this.interrupted = [];
22
23
  this.timedOut = [];
23
24
  this.flakey = [];
@@ -29,7 +30,7 @@ class JSONSummaryReporter {
29
30
  onBegin() {
30
31
  this.startedAt = Date.now();
31
32
  }
32
- onTestEnd(test, result) {
33
+ getTitle(test) {
33
34
  const title = [];
34
35
  const fileName = [];
35
36
  let clean = true;
@@ -39,35 +40,52 @@ class JSONSummaryReporter {
39
40
  }
40
41
  clean = false;
41
42
  title.push(s);
42
- if (s.includes('.ts') || s.includes('.js')) {
43
+ if (s.endsWith('.ts') || s.endsWith('.js')) {
43
44
  fileName.push(s);
44
45
  }
45
46
  }
46
- // This will publish the file name + line number test begins on
47
- const z = `${fileName[0]}`;
48
- // Using the t variable in the push will push a full test name + test description
49
- const t = title.join(' > ');
47
+
48
+ //Using the fullTitle variable in the push will push a full test name + test description
49
+
50
+ return {
51
+ fullTitle: title.join(' > '),
52
+ fileName: fileName[0] || ''
53
+ };
54
+ }
55
+ onTestEnd(test, result) {
56
+ const {
57
+ fullTitle,
58
+ fileName
59
+ } = this.getTitle(test);
60
+
50
61
  // Set the status
51
- const stepTitleList = result.steps.map(step => ({
62
+ const stepTitleList = result.steps.filter(step => step.error).map(step => ({
52
63
  title: step.title,
53
64
  error: step.error,
54
- testTitle: t
55
- })).filter(step => step.error !== undefined);
65
+ testTitle: fullTitle
66
+ }));
56
67
  if (stepTitleList.length > 0) {
57
68
  this.failedSteps = [...this.failedSteps, ...stepTitleList];
58
69
  }
59
- const status = !['passed', 'skipped'].includes(result.status) && t.includes('@warn') ? 'warned' : result.status;
70
+ const status = !['passed', 'skipped'].includes(result.status) && fullTitle.includes('@warn') ? 'warned' : result.status;
60
71
  // Logic to push the results into the correct array
61
72
  if (result.status === 'passed' && result.retry >= 1) {
62
- this.flakey.push(z);
73
+ this.flakey.push(fileName);
63
74
  } else {
64
- this[status].push(z);
75
+ this[status].push(fileName);
65
76
  }
66
- this[status].push(z);
77
+ this[status].push(fileName);
78
+ }
79
+ onError(error) {
80
+ this.errored.push({
81
+ error: error.message,
82
+ stack: error.stack
83
+ });
67
84
  }
68
85
  onEnd(result) {
69
86
  this.durationInMS = Date.now() - this.startedAt;
70
87
  this.status = result.status;
88
+
71
89
  // removing duplicate tests from passed array
72
90
  this.passed = this.passed.filter((element, index) => {
73
91
  return this.passed.indexOf(element) === index;
@@ -90,6 +108,14 @@ class JSONSummaryReporter {
90
108
  this.interrupted = this.interrupted.filter((element, index) => {
91
109
  return this.interrupted.indexOf(element) === index;
92
110
  });
111
+ this.errored = this.errored.filter((element, index) => {
112
+ return this.errored.indexOf(element) === index;
113
+ });
114
+ if (this.errored.length > 0) {
115
+ // Reflect setup failures in the final report status
116
+ this.status = "failed";
117
+ }
118
+
93
119
  // fs.writeFileSync('./summary.json', JSON.stringify(this, null, ' '));
94
120
  let {
95
121
  reportPath
package/jest.config.js CHANGED
@@ -22,7 +22,7 @@ module.exports = {
22
22
  'preprocessor',
23
23
  'jsPreprocessor.js'
24
24
  ),
25
- '^.+\\.jsx?$': 'babel-jest',
25
+ '^.+\\.jsx?$': 'babel-jest'
26
26
  },
27
27
 
28
28
  testMatch: ['**/__tests__/**/*.test.js'],
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.2.1",
3
+ "version": "0.3.2-experimental",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.3.1-experimental",
3
+ "version": "0.3.2-experimental",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -23,7 +23,7 @@
23
23
  "dependencies": {
24
24
  "@babel/preset-react": "7.22.5",
25
25
  "@cucumber/cucumber": "9.2.0",
26
- "@playwright/test": "1.47.1",
26
+ "@playwright/test": "1.42.1",
27
27
  "@testing-library/jest-dom": "5.11.9",
28
28
  "@testing-library/react": "11.2.7",
29
29
  "@testing-library/react-hooks": "7.0.2",
@@ -33,7 +33,7 @@
33
33
  "jest": "29.6.2",
34
34
  "jest-environment-jsdom": "29.6.2",
35
35
  "msw": "1.2.3",
36
- "playwright": "1.47.1",
36
+ "playwright": "1.42.1",
37
37
  "supports-color": "8.1.1"
38
38
  },
39
39
  "bin": {