monocart-coverage-reports 2.6.2 → 2.6.4

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.
@@ -154,6 +154,13 @@ const initSourceMapSourcePath = (sourceMap, fileUrls, sourcePathHandler) => {
154
154
  sourceMap.sourceRoot = '';
155
155
 
156
156
  sourceMap.sources = sourceMap.sources.map((sourceName, i) => {
157
+
158
+ // the sourceName could be absolute path
159
+ // c:\\workspace\test\\selenium.spec.js
160
+ // console.log(sourceName);
161
+ sourceName = Util.formatPath(sourceName);
162
+ // console.log(sourceName);
163
+
157
164
  const sourceUrl = mergeSourceRoot(sourceRoot, sourceName);
158
165
 
159
166
  let sourcePath = getSourcePath(sourceUrl, i + 1);
package/lib/v8/v8.js CHANGED
@@ -62,75 +62,82 @@ const initV8ListAndSourcemap = async (v8list, options) => {
62
62
  // filter no source or text
63
63
  // init type and css source from text
64
64
  // keep functions
65
- v8list = v8list.filter((item) => {
65
+ v8list = v8list.filter((entry) => {
66
66
 
67
67
  // filter entry
68
- if (!entryFilter(item)) {
69
- // console.log('-', item.url);
68
+ if (!entryFilter(entry)) {
69
+ // console.log('-', entry.url);
70
70
  return false;
71
71
  }
72
- // console.log(item.url);
72
+ // console.log(entry.url);
73
73
 
74
- if (typeof item.source === 'string' && item.functions) {
75
- item.type = 'js';
74
+ if (typeof entry.source === 'string' && entry.functions) {
75
+ entry.type = 'js';
76
76
  return true;
77
77
  }
78
- if (typeof item.text === 'string' && item.ranges) {
79
- item.type = 'css';
78
+ if (typeof entry.text === 'string' && entry.ranges) {
79
+ entry.type = 'css';
80
80
  return true;
81
81
  }
82
82
  // allow empty coverage
83
- if (item.empty) {
84
- if (!['js', 'css'].includes(item.type)) {
85
- item.type = 'js';
83
+ if (entry.empty) {
84
+ if (!['js', 'css'].includes(entry.type)) {
85
+ entry.type = 'js';
86
86
  }
87
87
  return true;
88
88
  }
89
89
  // 404 css, text will be empty
90
- // Util.logError(`Invalid source: ${item.url}`);
91
- // console.log(item);
90
+ // Util.logError(`Invalid source: ${entry.url}`);
91
+ // console.log(entry);
92
92
  });
93
93
 
94
94
 
95
- // do not change original v8list, to work for multiple APIs
95
+ // onEntry hook
96
+ // after filter but before init, because id depends source and sourcePath
97
+ const onEntry = options.onEntry;
98
+ if (typeof onEntry === 'function') {
99
+ for (const entry of v8list) {
100
+ await onEntry(entry);
101
+ }
102
+ }
96
103
 
97
104
  const sourcePathHandler = getSourcePathHandler(options);
98
105
 
99
106
  // init id, sourcePath
100
- v8list = v8list.map((item, i) => {
107
+ v8list = v8list.map((entry, i) => {
101
108
 
102
109
  // it could be a empty file
103
- let source = `${item.source || item.text || ''}`;
110
+ let source = `${entry.source || entry.text || ''}`;
104
111
 
105
112
  // fix source with script offset
106
113
  let scriptOffset;
107
- const offset = Util.toNum(item.scriptOffset, true);
114
+ const offset = Util.toNum(entry.scriptOffset, true);
108
115
  if (offset > 0) {
109
116
  scriptOffset = offset;
110
117
  source = getWrapperSource(offset, source);
111
118
  }
112
119
 
113
120
  const data = {
114
- url: item.url,
115
- type: item.type,
121
+ url: entry.url,
122
+ type: entry.type,
116
123
  source,
117
124
  // script offset >= 0, for vm script
118
125
  scriptOffset,
119
126
  // Manually Resolve the Sourcemap
120
- sourceMap: item.sourceMap,
127
+ sourceMap: entry.sourceMap,
121
128
  // fake source with `lineLengths`
122
- fake: item.fake,
129
+ fake: entry.fake,
123
130
  // empty coverage
124
- empty: item.empty,
131
+ empty: entry.empty,
125
132
  // match source if using empty coverage
126
- distFile: item.distFile
133
+ distFile: entry.distFile
127
134
  };
128
135
 
129
136
  // coverage
130
137
  if (data.type === 'js') {
131
- data.functions = item.functions;
138
+ data.functions = entry.functions;
132
139
  } else {
133
- data.ranges = item.ranges;
140
+ data.ranges = entry.ranges;
134
141
  }
135
142
 
136
143
  // resolve source path
@@ -335,7 +342,7 @@ const handleV8HtmlReport = async (reportData, reportOptions, options) => {
335
342
  return htmlPath;
336
343
  };
337
344
 
338
- const saveV8Report = async (v8list, options) => {
345
+ const saveV8Report = async (v8list, options, istanbulReportPath) => {
339
346
 
340
347
  const defaultWatermarks = {
341
348
  bytes: [50, 80],
@@ -378,9 +385,13 @@ const saveV8Report = async (v8list, options) => {
378
385
  }
379
386
  }
380
387
 
388
+ if (istanbulReportPath) {
389
+ outputs.istanbul = istanbulReportPath;
390
+ }
391
+
381
392
  // outputPath, should be html or json
382
393
  const reportPath = Util.resolveReportPath(options, () => {
383
- return outputs.v8 || outputs['v8-json'] || Object.values(outputs).filter((it) => it && typeof it === 'string').shift();
394
+ return outputs.v8 || outputs.istanbul || Object.values(outputs).filter((it) => it && typeof it === 'string').shift();
384
395
  });
385
396
 
386
397
  const coverageResults = {
package/package.json CHANGED
@@ -1,81 +1,81 @@
1
- {
2
- "name": "monocart-coverage-reports",
3
- "version": "2.6.2",
4
- "description": "Monocart coverage reports",
5
- "main": "./lib/index.js",
6
- "bin": {
7
- "mcr": "./lib/cli.js"
8
- },
9
- "exports": {
10
- ".": {
11
- "types": "./lib/index.d.ts",
12
- "import": "./lib/index.mjs",
13
- "require": "./lib/index.js",
14
- "default": "./lib/index.js"
15
- },
16
- "./package.json": "./package.json"
17
- },
18
- "types": "./lib/index.d.ts",
19
- "scripts": {
20
- "build-docs": "node ./scripts/build-docs.js",
21
- "build-test": "node ./scripts/build-test.js",
22
- "build": "sf lint && sf b -p && npm run build-test",
23
- "test-node": "npm run test-node-env && npm run test-node-api && npm run test-node-ins && npm run test-node-cdp && npm run test-node-koa && npm run test-node-vm",
24
- "test-node-env": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-env node ./test/test-node-env.js && node ./test/generate-report.js",
25
- "test-node-api": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-api node ./test/test-node-api.js",
26
- "test-node-fgc": "node ./test/test-node-fgc.js",
27
- "test-node-ins": "node ./test/test-node-ins.js",
28
- "test-node-cdp": "node --inspect=9229 ./test/test-node-cdp.js",
29
- "test-node-koa": "node ./test/test-node-koa.js",
30
- "test-node-vm": "node ./test/test-node-vm.js",
31
- "test-istanbul": "node ./test/test-istanbul.js",
32
- "test-v8": "node ./test/test-v8.js",
33
- "test-puppeteer": "node ./test/test-puppeteer.js",
34
- "test-browser": "node ./test/test-browser.js && npm run test-istanbul && npm run test-v8 && npm run test-puppeteer && npm run test-anonymous && npm run test-css",
35
- "test-anonymous": "node ./test/test-anonymous.js",
36
- "test-css": "node ./test/test-css.js",
37
- "test-cli": "npx mcr node ./test/test-node-env.js -o docs/cli -c test/cli-options.js",
38
- "test-merge": "node ./test/test-merge.js",
39
- "test-merge-istanbul": "node ./test/test-merge-istanbul.js",
40
- "test-all": "npm run test-browser && npm run test-node && npm run test-cli && npm run test-merge && npm run build-docs",
41
- "test": "npx mcr npm run test-all -c test/mcr-options.js",
42
- "test:snap": "cross-env TEST_SNAPSHOT=true npm run test",
43
- "dev": "sf d v8",
44
- "open": "node ./scripts/open.js",
45
- "patch": "npm run build && sf publish patch -r"
46
- },
47
- "workspaces": [
48
- "packages/*",
49
- "test"
50
- ],
51
- "files": [
52
- "lib"
53
- ],
54
- "license": "MIT",
55
- "repository": {
56
- "type": "git",
57
- "url": "git+https://github.com/cenfun/monocart-coverage-reports.git"
58
- },
59
- "dependencies": {
60
- "console-grid": "~2.2.2",
61
- "eight-colors": "~1.3.0",
62
- "istanbul-lib-coverage": "~3.2.2",
63
- "istanbul-lib-report": "~3.0.1",
64
- "istanbul-reports": "~3.1.7",
65
- "lz-utils": "~2.0.2",
66
- "monocart-code-viewer": "~1.1.1",
67
- "monocart-formatter": "~2.3.2",
68
- "turbogrid": "~3.0.13"
69
- },
70
- "devDependencies": {
71
- "commander": "^12.0.0",
72
- "eslint": "^8.57.0",
73
- "eslint-config-plus": "^1.0.6",
74
- "eslint-plugin-html": "^8.0.0",
75
- "eslint-plugin-vue": "^9.22.0",
76
- "minimatch": "^9.0.3",
77
- "stylelint": "^15.11.0",
78
- "stylelint-config-plus": "^1.0.4",
79
- "supports-color": "^9.4.0"
80
- }
81
- }
1
+ {
2
+ "name": "monocart-coverage-reports",
3
+ "version": "2.6.4",
4
+ "description": "Code coverage tool to generate native V8 reports or Istanbul reports.",
5
+ "main": "./lib/index.js",
6
+ "bin": {
7
+ "mcr": "./lib/cli.js"
8
+ },
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/index.d.ts",
12
+ "import": "./lib/index.mjs",
13
+ "require": "./lib/index.js",
14
+ "default": "./lib/index.js"
15
+ },
16
+ "./package.json": "./package.json"
17
+ },
18
+ "types": "./lib/index.d.ts",
19
+ "scripts": {
20
+ "build-docs": "node ./scripts/build-docs.js",
21
+ "build-test": "node ./scripts/build-test.js",
22
+ "build": "sf lint && sf b -p && npm run build-test",
23
+ "test-node": "npm run test-node-env && npm run test-node-api && npm run test-node-ins && npm run test-node-cdp && npm run test-node-koa && npm run test-node-vm",
24
+ "test-node-env": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-env node ./test/test-node-env.js && node ./test/generate-report.js",
25
+ "test-node-api": "cross-env NODE_V8_COVERAGE=.temp/v8-coverage-api node ./test/test-node-api.js",
26
+ "test-node-fgc": "node ./test/test-node-fgc.js",
27
+ "test-node-ins": "node ./test/test-node-ins.js",
28
+ "test-node-cdp": "node --inspect=9229 ./test/test-node-cdp.js",
29
+ "test-node-koa": "node ./test/test-node-koa.js",
30
+ "test-node-vm": "node ./test/test-node-vm.js",
31
+ "test-istanbul": "node ./test/test-istanbul.js",
32
+ "test-v8": "node ./test/test-v8.js",
33
+ "test-puppeteer": "node ./test/test-puppeteer.js",
34
+ "test-browser": "node ./test/test-browser.js && npm run test-istanbul && npm run test-v8 && npm run test-puppeteer && npm run test-anonymous && npm run test-css",
35
+ "test-anonymous": "node ./test/test-anonymous.js",
36
+ "test-css": "node ./test/test-css.js",
37
+ "test-cli": "npx mcr node ./test/specs/node.test.js -c test/mcr.config.cli.js",
38
+ "test-merge": "node ./test/test-merge.js",
39
+ "test-merge-istanbul": "node ./test/test-merge-istanbul.js",
40
+ "test-all": "npm run test-browser && npm run test-node && npm run test-cli && npm run test-merge && npm run build-docs",
41
+ "test": "npx mcr npm run test-all -c test/mcr.config.mcr.js",
42
+ "test:snap": "cross-env TEST_SNAPSHOT=true npm run test",
43
+ "dev": "sf d v8",
44
+ "open": "node ./scripts/open.js",
45
+ "patch": "npm run build && npm run test && sf publish patch -r"
46
+ },
47
+ "workspaces": [
48
+ "packages/*",
49
+ "test"
50
+ ],
51
+ "files": [
52
+ "lib"
53
+ ],
54
+ "license": "MIT",
55
+ "repository": {
56
+ "type": "git",
57
+ "url": "git+https://github.com/cenfun/monocart-coverage-reports.git"
58
+ },
59
+ "dependencies": {
60
+ "console-grid": "~2.2.2",
61
+ "eight-colors": "~1.3.0",
62
+ "istanbul-lib-coverage": "~3.2.2",
63
+ "istanbul-lib-report": "~3.0.1",
64
+ "istanbul-reports": "~3.1.7",
65
+ "lz-utils": "~2.0.2",
66
+ "monocart-code-viewer": "~1.1.1",
67
+ "monocart-formatter": "~2.3.2",
68
+ "turbogrid": "~3.0.13"
69
+ },
70
+ "devDependencies": {
71
+ "commander": "^12.0.0",
72
+ "eslint": "^8.57.0",
73
+ "eslint-config-plus": "^1.0.6",
74
+ "eslint-plugin-html": "^8.0.0",
75
+ "eslint-plugin-vue": "^9.22.0",
76
+ "minimatch": "^9.0.3",
77
+ "stylelint": "^15.11.0",
78
+ "stylelint-config-plus": "^1.0.4",
79
+ "supports-color": "^9.4.0"
80
+ }
81
+ }