monocart-coverage-reports 2.12.3 → 2.12.5
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 +1 -1
- package/README.zh-Hans.md +1 -1
- package/lib/converter/collect-source-maps.js +13 -2
- package/lib/converter/converter.js +1 -1
- package/lib/default/options.js +6 -0
- package/lib/index.d.ts +10 -0
- package/lib/packages/monocart-coverage-assets.js +1 -1
- package/lib/packages/monocart-coverage-vendor.js +14 -14
- package/package.json +17 -18
package/README.md
CHANGED
|
@@ -297,7 +297,7 @@ const coverageData = [... jsCoverage, ... cssCoverage];
|
|
|
297
297
|
|
|
298
298
|
```
|
|
299
299
|
Collect coverage with `@playwright/test` [`Automatic fixtures`](https://playwright.dev/docs/test-fixtures#automatic-fixtures), see example: [fixtures.ts](https://github.com/cenfun/playwright-coverage/blob/main/fixtures.ts)
|
|
300
|
-
For more examples, see [./test/test-v8.js](./test/test-v8.js),
|
|
300
|
+
For more examples, see [./test/test-v8.js](./test/test-v8.js), [css](./test/test-css.js)
|
|
301
301
|
|
|
302
302
|
|
|
303
303
|
### Collecting Raw V8 Coverage Data with Puppeteer
|
package/README.zh-Hans.md
CHANGED
|
@@ -299,7 +299,7 @@ const coverageData = [... jsCoverage, ... cssCoverage];
|
|
|
299
299
|
|
|
300
300
|
```
|
|
301
301
|
使用 `@playwright/test` 的 [`Automatic fixtures`](https://playwright.dev/docs/test-fixtures#automatic-fixtures)收集覆盖率数据, 见例子: [fixtures.ts](https://github.com/cenfun/playwright-coverage/blob/main/fixtures.ts)
|
|
302
|
-
参见例子 [./test/test-v8.js](./test/test-v8.js),
|
|
302
|
+
参见例子 [./test/test-v8.js](./test/test-v8.js), [css](./test/test-css.js)
|
|
303
303
|
|
|
304
304
|
|
|
305
305
|
### Collecting Raw V8 Coverage Data with Puppeteer
|
|
@@ -8,7 +8,7 @@ const { flattenSourceMaps } = require('./flatten-source-maps.js');
|
|
|
8
8
|
|
|
9
9
|
const Util = require('../utils/util.js');
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const defaultSourceMapResolver = async (url = '') => {
|
|
12
12
|
|
|
13
13
|
if (url.startsWith('file:')) {
|
|
14
14
|
const p = fileURLToPath(url);
|
|
@@ -37,6 +37,17 @@ const loadSourceMap = async (url = '') => {
|
|
|
37
37
|
return content;
|
|
38
38
|
};
|
|
39
39
|
|
|
40
|
+
const loadSourceMap = async (url, options) => {
|
|
41
|
+
if (typeof options.sourceMapResolver === 'function') {
|
|
42
|
+
const content = await options.sourceMapResolver(url, defaultSourceMapResolver);
|
|
43
|
+
if (typeof content === 'string') {
|
|
44
|
+
return Util.jsonParse(content);
|
|
45
|
+
}
|
|
46
|
+
return content;
|
|
47
|
+
}
|
|
48
|
+
return defaultSourceMapResolver(url);
|
|
49
|
+
};
|
|
50
|
+
|
|
40
51
|
const getSourceMapUrl = (content, url) => {
|
|
41
52
|
|
|
42
53
|
const m = content.match(convertSourceMap.mapFileCommentRegex);
|
|
@@ -250,7 +261,7 @@ const collectSourceMaps = async (v8list, options) => {
|
|
|
250
261
|
await concurrency.start(async (item) => {
|
|
251
262
|
const { sourceMapUrl, sourceData } = item;
|
|
252
263
|
const { url } = sourceData;
|
|
253
|
-
const data = await loadSourceMap(sourceMapUrl);
|
|
264
|
+
const data = await loadSourceMap(sourceMapUrl, options);
|
|
254
265
|
if (data) {
|
|
255
266
|
sourceData.sourceMap = resolveSourceMap(data, url);
|
|
256
267
|
sourcemapList.push({
|
|
@@ -1037,7 +1037,7 @@ const initOriginalList = (state, originalDecodedMap, options) => {
|
|
|
1037
1037
|
// console.log(sourcePath);
|
|
1038
1038
|
|
|
1039
1039
|
// console.log(`add source: ${k}`);
|
|
1040
|
-
const sourceContent = sourcesContent[sourceIndex];
|
|
1040
|
+
const sourceContent = sourcesContent?.[sourceIndex];
|
|
1041
1041
|
if (typeof sourceContent !== 'string') {
|
|
1042
1042
|
Util.logError(`not found source content: ${sourcePath}`);
|
|
1043
1043
|
return;
|
package/lib/default/options.js
CHANGED
|
@@ -91,6 +91,12 @@ module.exports = {
|
|
|
91
91
|
// {number} gc threshold
|
|
92
92
|
gc: null,
|
|
93
93
|
|
|
94
|
+
// {boolean} Indicates whether to save source and sourcemap file for debug (require logging="debug")
|
|
95
|
+
sourceMap: false,
|
|
96
|
+
|
|
97
|
+
// {function} Custom resolver for sourcemap content
|
|
98
|
+
sourceMapResolver: null,
|
|
99
|
+
|
|
94
100
|
// {function} onEntry hook
|
|
95
101
|
// onEntry: async (entry) => {}
|
|
96
102
|
onEntry: null,
|
package/lib/index.d.ts
CHANGED
|
@@ -411,6 +411,16 @@ declare namespace MCR {
|
|
|
411
411
|
*/
|
|
412
412
|
gc?: number;
|
|
413
413
|
|
|
414
|
+
/**
|
|
415
|
+
* {boolean} Indicates whether to save source and sourcemap file for debug (require logging="debug")
|
|
416
|
+
*/
|
|
417
|
+
sourceMap?: boolean;
|
|
418
|
+
|
|
419
|
+
/**
|
|
420
|
+
* {function} Custom resolver for sourcemap content
|
|
421
|
+
*/
|
|
422
|
+
sourceMapResolver?: (url: string, defaultResolver: function) => Promise<any>;
|
|
423
|
+
|
|
414
424
|
/** (V8 only) {function} onEntry hook */
|
|
415
425
|
onEntry?: (entry: V8CoverageEntry) => Promise<void>;
|
|
416
426
|
|