monocart-reporter 2.0.0 → 2.0.2

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.
@@ -32,17 +32,20 @@ const attachCoverageReport = async (data, testInfo, options = {}) => {
32
32
  await coverageReport.add(data);
33
33
  const coverageResults = await coverageReport.generate();
34
34
 
35
- // save report json
36
- const definition = Util.attachments.coverage;
37
- const reportPath = path.resolve(htmlDir, definition.reportFile);
38
- Util.writeJSONSync(reportPath, coverageResults);
39
-
40
- // save attachments html link
41
- testInfo.attachments.push({
42
- name: definition.name,
43
- contentType: definition.contentType,
44
- path: coverageResults.reportPath
45
- });
35
+ const reportPath = coverageResults.reportPath;
36
+ if (reportPath && fs.existsSync(reportPath)) {
37
+ // save report json
38
+ const definition = Util.attachments.coverage;
39
+ const reportJsonPath = path.resolve(htmlDir, definition.reportFile);
40
+ Util.writeJSONSync(reportJsonPath, coverageResults);
41
+
42
+ // save attachments html link
43
+ testInfo.attachments.push({
44
+ name: definition.name,
45
+ contentType: definition.contentType,
46
+ path: reportPath
47
+ });
48
+ }
46
49
 
47
50
  return coverageResults;
48
51
  };
@@ -101,12 +104,16 @@ const generateGlobalCoverageReport = async (reporterOptions) => {
101
104
 
102
105
  // console.log('global coverage report', report);
103
106
 
104
- return {
105
- global: true,
106
- type: 'coverage',
107
- name: coverageResults.name,
108
- path: coverageResults.reportPath
109
- };
107
+ const reportPath = coverageResults.reportPath;
108
+ if (reportPath && fs.existsSync(reportPath)) {
109
+ return {
110
+ global: true,
111
+ type: 'coverage',
112
+ name: coverageResults.name,
113
+ path: reportPath
114
+ };
115
+ }
116
+
110
117
  };
111
118
 
112
119
  module.exports = {
@@ -100,11 +100,11 @@ const saveNetworkHtmlReport = async (reportData, _options) => {
100
100
 
101
101
  // deps
102
102
  const jsFiles = ['monocart-code-viewer', 'monocart-formatter', 'turbogrid'].map((it) => {
103
- return path.resolve(`node_modules/${it}/dist/${it}.js`);
103
+ return Util.resolveNodeModule(`${it}/dist/${it}.js`);
104
104
  });
105
105
 
106
- jsFiles.push(path.resolve(__dirname, '../../packages/monocart-common.js'));
107
- jsFiles.push(path.resolve(__dirname, '../../packages/monocart-network.js'));
106
+ jsFiles.push(Util.resolvePackage('monocart-common.js'));
107
+ jsFiles.push(Util.resolvePackage('monocart-network.js'));
108
108
 
109
109
  const options = {
110
110
  inline,
package/lib/utils/util.js CHANGED
@@ -151,6 +151,34 @@ const Util = {
151
151
  Util.initDir(assetsDir);
152
152
  },
153
153
 
154
+ resolveNodeModule: (p) => {
155
+ // same level dep
156
+ const dep = path.resolve(__dirname, '../../../', p);
157
+ if (fs.existsSync(dep)) {
158
+ return dep;
159
+ }
160
+
161
+ // root
162
+ const cwd = path.resolve('node_modules', p);
163
+ if (fs.existsSync(cwd)) {
164
+ return cwd;
165
+ }
166
+
167
+ // sub node modules
168
+ const sub = path.resolve(__dirname, '../../node_modules', p);
169
+ if (fs.existsSync(sub)) {
170
+ return sub;
171
+ }
172
+
173
+ Util.logError(`Not found module: ${p}`);
174
+
175
+ return cwd;
176
+ },
177
+
178
+ resolvePackage: (p) => {
179
+ return path.resolve(__dirname, '../packages', p);
180
+ },
181
+
154
182
  saveHtmlReport: async (options) => {
155
183
 
156
184
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monocart-reporter",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "A playwright test reporter. Shows suites/cases/steps with tree style, markdown annotations, custom columns/formatters/data collection visitors, console logs, style tags, send email.",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
@@ -48,7 +48,7 @@
48
48
  "koa": "^2.14.2",
49
49
  "koa-static-resolver": "^1.0.4",
50
50
  "lz-utils": "^2.0.1",
51
- "monocart-coverage-reports": "^1.0.6",
51
+ "monocart-coverage-reports": "^1.0.8",
52
52
  "nodemailer": "^6.9.7",
53
53
  "open": "^9.1.0",
54
54
  "turbogrid": "^3.0.10"
@@ -61,7 +61,7 @@
61
61
  "eslint-config-plus": "^1.0.6",
62
62
  "eslint-plugin-html": "^7.1.0",
63
63
  "eslint-plugin-vue": "^9.19.2",
64
- "stylelint": "^15.11.0",
64
+ "stylelint": "^16.0.2",
65
65
  "stylelint-config-plus": "^1.0.4",
66
66
  "vine-ui": "^3.1.12"
67
67
  }