@zohodesk/testinglibrary 0.1.7 → 0.1.8

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.
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = exports.default = {
8
+ addTags: [async ({
9
+ $tags
10
+ }, use, testInfo) => {
11
+ testInfo.annotations.push({
12
+ type: 'tags',
13
+ description: $tags.join(', ')
14
+ });
15
+ await use();
16
+ }, {
17
+ auto: true
18
+ }]
19
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ const cacheMap = new Map();
8
+ var _default = exports.default = {
9
+ cacheLayer: async ({}, use) => {
10
+ await use(cacheMap);
11
+ }
12
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = exports.default = {
8
+ context: async ({
9
+ context
10
+ }, use) => {
11
+ // eslint-disable-next-line no-undef
12
+ await context.addInitScript(() => window.localStorage.setItem('isDnBannerHide', true));
13
+ await use(context);
14
+ }
15
+ };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _page = _interopRequireDefault(require("./page"));
9
+ var _context = _interopRequireDefault(require("./context"));
10
+ var _cacheLayer = _interopRequireDefault(require("./cacheLayer"));
11
+ var _addTags = _interopRequireDefault(require("./addTags"));
12
+ function getBuiltInFixtures(bddMode) {
13
+ let builtInFixtures = {
14
+ ..._page.default,
15
+ ..._context.default,
16
+ ..._cacheLayer.default
17
+ };
18
+ if (bddMode) {
19
+ builtInFixtures = {
20
+ ...builtInFixtures,
21
+ ..._addTags.default
22
+ };
23
+ }
24
+ return builtInFixtures;
25
+ }
26
+ var _default = exports.default = getBuiltInFixtures;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ // function test(descrition, callback) {
8
+ // return test(descrition, ({ page }) => {
9
+ // const { locator, ...custompage } = page
10
+ // callback({ page: custompage })
11
+ // })
12
+ // }
13
+ // class FilteredPage {
14
+ // constructor(page) {
15
+ // this.page = page;
16
+ // this.allowedMethods = ['getByText', 'getByTitle'];
17
+ // this.context = page.context;
18
+ // }
19
+ // goto(...args) {
20
+ // return this.page['goto'](...args);
21
+ // }
22
+ // getByRole(...args) {
23
+ // return this.page['getByRole'](...args);
24
+ // }
25
+ // }
26
+ // function FilteredPage(page) {
27
+ // return {
28
+ // getByRole: () => {
29
+ // throw new Error('You cannnot use getByRole property')
30
+ // }
31
+ // }
32
+ // }
33
+ var _default = exports.default = {
34
+ page: async ({
35
+ page
36
+ }, use) => {
37
+ page.getBaseUrl = function () {
38
+ if (process.env.mode === 'dev') {
39
+ return `${process.env.domain}?devURL=${process.env.devUrl}`;
40
+ }
41
+ return `${process.env.domain}`;
42
+ };
43
+ page.getCustomPageUrl = function (url) {
44
+ if (process.env.mode === 'dev') {
45
+ return `${process.env.domain}/${url}?devURL=${process.env.devUrl}`;
46
+ }
47
+ return `${process.env.domain}/${url}`;
48
+ };
49
+ await use(page);
50
+ }
51
+ };
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -20,100 +21,16 @@ exports.test = void 0;
20
21
  var _bddFramework = require("../../bdd-framework");
21
22
  var _test = require("@playwright/test");
22
23
  var _readConfigFile = require("./readConfigFile");
23
- // function test(descrition, callback) {
24
- // return test(descrition, ({ page }) => {
25
- // const { locator, ...custompage } = page
26
- // callback({ page: custompage })
27
- // })
28
- // }
29
-
30
- // class FilteredPage {
31
- // constructor(page) {
32
- // this.page = page;
33
- // this.allowedMethods = ['getByText', 'getByTitle'];
34
- // this.context = page.context;
35
- // }
36
-
37
- // goto(...args) {
38
- // return this.page['goto'](...args);
39
- // }
40
-
41
- // getByRole(...args) {
42
- // return this.page['getByRole'](...args);
43
- // }
44
- // }
45
-
46
- // function FilteredPage(page) {
47
- // return {
48
- // getByRole: () => {
49
- // throw new Error('You cannnot use getByRole property')
50
- // }
51
- // }
52
- // }
24
+ var _builtInFixtures = _interopRequireDefault(require("./builtInFixtures"));
53
25
  const {
54
- additionalPages,
26
+ additionalPages: userFixtures,
55
27
  bddMode
56
28
  } = (0, _readConfigFile.generateConfigFromFile)();
57
29
  let base = bddMode ? _bddFramework.test : _test.test;
58
- const cacheMap = new Map();
30
+ const buildInFixtures = (0, _builtInFixtures.default)(bddMode);
59
31
  const test = exports.test = base.extend({
60
- page: async ({
61
- page
62
- }, use) => {
63
- // const proxyPage = new Proxy(page, {
64
- // get: function (obj, prop) {
65
- // console.log('Gettig Priop', prop);
66
- // let filterMethod = FilteredPage(page)[prop];
67
- // if (filterMethod) {
68
- // return filterMethod;
69
- // } else {
70
- // return obj[prop] ? obj[prop] : 'property does not exist';
71
- // }
72
- // }
73
- // })
74
- page.getBaseUrl = function () {
75
- if (process.env.mode === 'dev') {
76
- return `${process.env.domain}?devURL=${process.env.devUrl}`;
77
- }
78
- return `${process.env.domain}`;
79
- };
80
- page.getCustomPageUrl = function (url) {
81
- if (process.env.mode === 'dev') {
82
- return `${process.env.domain}/${url}?devURL=${process.env.devUrl}`;
83
- }
84
- return `${process.env.domain}/${url}`;
85
- };
86
- await use(page);
87
-
88
- //await use(new FilteredPage(page));
89
-
90
- // await use(async (page) => {
91
- // delete page.getByTestId;
92
- // await page;
93
- // });
94
- },
95
- context: async ({
96
- context
97
- }, use) => {
98
- // eslint-disable-next-line no-undef
99
- await context.addInitScript(() => window.localStorage.setItem('isDnBannerHide', true));
100
- await use(context);
101
- },
102
- cacheLayer: async ({}, use) => {
103
- await use(cacheMap);
104
- },
105
- addTags: [async ({
106
- $tags
107
- }, use, testInfo) => {
108
- testInfo.annotations.push({
109
- type: 'tags',
110
- description: $tags.join(', ')
111
- });
112
- await use();
113
- }, {
114
- auto: true
115
- }],
116
- ...additionalPages
32
+ ...buildInFixtures,
33
+ ...userFixtures
117
34
  });
118
35
  const {
119
36
  Given,
@@ -20,6 +20,7 @@ class JSONSummaryReporter {
20
20
  this.interrupted = [];
21
21
  this.timedOut = [];
22
22
  this.flakey = [];
23
+ this.failedSteps = [];
23
24
  this.status = 'unknown';
24
25
  this.startedAt = 0;
25
26
  this._open = (0, _readConfigFile.generateConfigFromFile)().openReportOn;
@@ -46,6 +47,14 @@ class JSONSummaryReporter {
46
47
  // Using the t variable in the push will push a full test name + test description
47
48
  const t = title.join(' > ');
48
49
  // Set the status
50
+ const stepTitleList = result.steps.map(step => ({
51
+ title: step.title,
52
+ error: step.error,
53
+ testTitle: t
54
+ })).filter(step => step.error !== undefined);
55
+ if (stepTitleList.length > 0) {
56
+ this.failedSteps = [...this.failedSteps, ...stepTitleList];
57
+ }
49
58
  const status = !['passed', 'skipped'].includes(result.status) && t.includes('@warn') ? 'warned' : result.status;
50
59
  // Logic to push the results into the correct array
51
60
  if (result.status === 'passed' && result.retry >= 1) {
@@ -10,6 +10,7 @@ exports.deleteFolder = deleteFolder;
10
10
  exports.readFileContents = readFileContents;
11
11
  exports.writeFileContents = writeFileContents;
12
12
  var _fs = _interopRequireDefault(require("fs"));
13
+ var _path = _interopRequireDefault(require("path"));
13
14
  function checkIfFileExists(file) {
14
15
  try {
15
16
  _fs.default.accessSync(file, _fs.default.constants.F_OK);
@@ -27,9 +28,7 @@ function readFileContents(filePath) {
27
28
  }
28
29
  }
29
30
  function writeFileContents(filePath, content, writeOptions = {}) {
30
- let filePaths = filePath.split('/');
31
- let fileName = filePaths.pop();
32
- let directoryPath = filePaths.join('/');
31
+ const directoryPath = _path.default.dirname(filePath);
33
32
 
34
33
  // Check if the directory exists
35
34
  if (!_fs.default.existsSync(directoryPath)) {
@@ -38,7 +37,7 @@ function writeFileContents(filePath, content, writeOptions = {}) {
38
37
  });
39
38
  }
40
39
  try {
41
- _fs.default.writeFileSync(`${directoryPath}/${fileName}`, content, writeOptions);
40
+ _fs.default.writeFileSync(`${filePath}`, content, writeOptions);
42
41
  } catch (err) {
43
42
  throw new Error(err);
44
43
  }
package/changelog.md CHANGED
@@ -1,6 +1,13 @@
1
1
  # Testing Framework
2
2
 
3
3
  ## Framework that abstracts the configuration for playwright and Jest
4
+ # 0.1.8
5
+ **Issue Fixes**
6
+ - Fix #9 Custom report generate Error on Windows
7
+ - Add Tags annotations only on bddMode
8
+
9
+ **Enhancements**
10
+ - Added Failed steps in test summary
4
11
 
5
12
  # 0.1.7
6
13
  **Enhancements**
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zohodesk/testinglibrary",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
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.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {