@zohodesk/testinglibrary 0.2.7 → 0.2.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.
- package/.babelrc +2 -1
- package/README.md +10 -1
- package/build/core/jest/preprocessor/jsPreprocessor.js +2 -7
- package/build/core/jest/setup/index.js +0 -6
- package/build/core/playwright/setup/custom-reporter.js +39 -13
- package/jest.config.js +11 -3
- package/npm-shrinkwrap.json +1 -1
- package/package.json +2 -2
package/.babelrc
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
]
|
|
14
14
|
],
|
|
15
15
|
"plugins": [
|
|
16
|
-
["@babel/plugin-transform-runtime"]
|
|
16
|
+
["@babel/plugin-transform-runtime"],
|
|
17
|
+
["@babel/plugin-transform-modules-commonjs"]
|
|
17
18
|
],
|
|
18
19
|
// Ignored as these are setup files needed during init script. Files inside that folder are copied not transformed
|
|
19
20
|
"ignore": [
|
package/README.md
CHANGED
|
@@ -15,4 +15,13 @@
|
|
|
15
15
|
### Generate Report
|
|
16
16
|
|
|
17
17
|
- npm run report
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
## Version History
|
|
20
|
+
|
|
21
|
+
### v0.2.8 - 26-09-2024
|
|
22
|
+
|
|
23
|
+
#### Feature
|
|
24
|
+
- Added support for writing unitcases for framework implementations
|
|
25
|
+
|
|
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.
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _babelJest = _interopRequireDefault(require("babel-jest"));
|
|
9
|
-
var _default = exports.default = _babelJest.default.createTransformer({
|
|
3
|
+
const babelJest = require('babel-jest');
|
|
4
|
+
module.exports = babelJest.createTransformer({
|
|
10
5
|
presets: [require.resolve('@babel/preset-env'), require.resolve('@babel/preset-react')],
|
|
11
6
|
plugins: [require.resolve('babel-plugin-transform-dynamic-import')]
|
|
12
7
|
});
|
|
@@ -1,9 +1,3 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
var _testUtils = _interopRequireDefault(require("react-dom/test-utils"));
|
|
5
|
-
var _globals = require("@jest/globals");
|
|
6
|
-
var _react = _interopRequireDefault(require("react"));
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _reactDom = _interopRequireDefault(require("react-dom"));
|
|
9
3
|
require("@testing-library/jest-dom/extend-expect");
|
|
@@ -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
|
-
|
|
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.
|
|
43
|
+
if (s.endsWith('.ts') || s.endsWith('.js')) {
|
|
43
44
|
fileName.push(s);
|
|
44
45
|
}
|
|
45
46
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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:
|
|
55
|
-
}))
|
|
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) &&
|
|
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(
|
|
73
|
+
this.flakey.push(fileName);
|
|
63
74
|
} else {
|
|
64
|
-
this[status].push(
|
|
75
|
+
this[status].push(fileName);
|
|
65
76
|
}
|
|
66
|
-
this[status].push(
|
|
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
|
@@ -6,7 +6,7 @@ const appGlobals = path.resolve(appPath, '__testUtils__', 'globals.js');
|
|
|
6
6
|
|
|
7
7
|
module.exports = {
|
|
8
8
|
rootDir: process.cwd(),
|
|
9
|
-
testEnvironment: '
|
|
9
|
+
testEnvironment: 'node',
|
|
10
10
|
|
|
11
11
|
setupFilesAfterEnv: [
|
|
12
12
|
existsSync(appGlobals) && appGlobals,
|
|
@@ -21,13 +21,21 @@ module.exports = {
|
|
|
21
21
|
'jest',
|
|
22
22
|
'preprocessor',
|
|
23
23
|
'jsPreprocessor.js'
|
|
24
|
-
)
|
|
24
|
+
),
|
|
25
|
+
'^.+\\.jsx?$': 'babel-jest'
|
|
25
26
|
},
|
|
27
|
+
|
|
28
|
+
testMatch: ['**/__tests__/**/*.test.js'],
|
|
26
29
|
|
|
27
30
|
modulePathIgnorePatterns: ['/build/'],
|
|
28
31
|
|
|
29
32
|
transformIgnorePatterns: [
|
|
30
|
-
'/node_modules/
|
|
33
|
+
'/node_modules/',
|
|
34
|
+
'/src/setup-folder-structure/samples/'
|
|
35
|
+
],
|
|
36
|
+
|
|
37
|
+
coveragePathIgnorePatterns:[
|
|
38
|
+
'/src/setup-folder-structure/samples/'
|
|
31
39
|
],
|
|
32
40
|
|
|
33
41
|
testPathIgnorePatterns: [
|
package/npm-shrinkwrap.json
CHANGED
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zohodesk/testinglibrary",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"postinstall": "node bin/postinstall.js",
|
|
8
|
-
"test": "
|
|
8
|
+
"test": "jest",
|
|
9
9
|
"clean": "rm -rf build && mkdir build",
|
|
10
10
|
"build-babel": "babel -d ./build ./src --copy-files",
|
|
11
11
|
"build": "npm run clean && npm run build-babel",
|