monocart-coverage-reports 2.2.0 → 2.2.1
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 +136 -126
- package/lib/utils/source-path.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* [Usage](#usage)
|
|
12
12
|
* [Default Options](#default-options)
|
|
13
13
|
* [Available Reports](#available-reports)
|
|
14
|
-
* [
|
|
14
|
+
* [Using `entryFilter` and `sourceFilter` to filter the results for V8 report](#using-entryfilter-and-sourcefilter-to-filter-the-results-for-v8-report)
|
|
15
15
|
* [onEnd Hook](#onend-hook)
|
|
16
16
|
* [`mcr` CLI](#mcr-cli)
|
|
17
17
|
* [Compare Reports](#compare-reports)
|
|
@@ -19,13 +19,14 @@
|
|
|
19
19
|
* [Collecting Istanbul Coverage Data](#collecting-istanbul-coverage-data)
|
|
20
20
|
* [Collecting V8 Coverage Data](#collecting-v8-coverage-data)
|
|
21
21
|
* [Node.js V8 Coverage Report for Server Side](#nodejs-v8-coverage-report-for-server-side)
|
|
22
|
-
* [
|
|
22
|
+
* [Multiprocessing Support](#multiprocessing-support)
|
|
23
|
+
* [Integration](#integration)
|
|
24
|
+
* [Ignoring Uncovered Codes](#ignoring-uncovered-codes)
|
|
25
|
+
* [Chromium Coverage API](#chromium-coverage-api)
|
|
26
|
+
* [V8 Coverage Data Format](#v8-coverage-data-format)
|
|
23
27
|
* [How to convert V8 to Istanbul](#how-to-convert-v8-to-istanbul)
|
|
24
28
|
- [Using `v8-to-istanbul`](#using-v8-to-istanbul)
|
|
25
29
|
- [How Monocart Works](#how-monocart-works)
|
|
26
|
-
* [Ignoring Uncovered Lines](#ignoring-uncovered-lines)
|
|
27
|
-
* [Chromium Coverage API](#chromium-coverage-api)
|
|
28
|
-
* [V8 Coverage Data Format](#v8-coverage-data-format)
|
|
29
30
|
* [Istanbul Introduction](#istanbul-introduction)
|
|
30
31
|
* [Thanks](#thanks)
|
|
31
32
|
|
|
@@ -54,6 +55,7 @@ console.log(coverageResults.summary);
|
|
|
54
55
|
- Build with webpack: [V8](https://cenfun.github.io/monocart-coverage-reports/v8) and [V8 Minify](https://cenfun.github.io/monocart-coverage-reports/v8-minify)
|
|
55
56
|
- Build with [Rollup](https://cenfun.github.io/monocart-coverage-reports/v8-rollup) and [Esbuild](https://cenfun.github.io/monocart-coverage-reports/v8-esbuild)
|
|
56
57
|
- Collect with [puppeteer](https://cenfun.github.io/monocart-coverage-reports/puppeteer/)
|
|
58
|
+
- [anonymous](https://cenfun.github.io/monocart-coverage-reports/anonymous/) and [css](https://cenfun.github.io/monocart-coverage-reports/css/)
|
|
57
59
|
- Test in Node.js
|
|
58
60
|
- Collect with [env](https://cenfun.github.io/monocart-coverage-reports/v8-node-env), and also V8 [API](https://cenfun.github.io/monocart-coverage-reports/v8-node-api), [Inspector](https://cenfun.github.io/monocart-coverage-reports/v8-node-ins) and [CDP](https://cenfun.github.io/monocart-coverage-reports/v8-node-cdp)
|
|
59
61
|
- Web server example: [koa](https://cenfun.github.io/monocart-coverage-reports/v8-node-koa/)
|
|
@@ -105,37 +107,34 @@ const options = {
|
|
|
105
107
|
const coverageReport = MCR(options);
|
|
106
108
|
```
|
|
107
109
|
|
|
108
|
-
##
|
|
109
|
-
|
|
110
|
-
- [vitest-monocart-coverage](https://github.com/cenfun/vitest-monocart-coverage) - Integration with [Vitest](https://github.com/vitest-dev/vitest) coverage
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
## Multiprocessing Support
|
|
114
|
-
The data will be added to `[outputDir]/.cache`, and the cache will be removed after reports generated.
|
|
115
|
-
- sub process 1
|
|
116
|
-
```js
|
|
117
|
-
const MCR = require('monocart-coverage-reports');
|
|
118
|
-
const options = require('path-to/same-options.js');
|
|
119
|
-
const coverageReport = MCR(options);
|
|
120
|
-
await coverageReport.add(coverageData1);
|
|
110
|
+
## Using `entryFilter` and `sourceFilter` to filter the results for V8 report
|
|
111
|
+
When V8 coverage data collected, it actually contains the data of all entry files, for example:
|
|
121
112
|
```
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const MCR = require('monocart-coverage-reports');
|
|
126
|
-
const options = require('path-to/same-options.js');
|
|
127
|
-
const coverageReport = MCR(options);
|
|
128
|
-
await coverageReport.add(coverageData2);
|
|
113
|
+
dist/main.js
|
|
114
|
+
dist/vendor.js
|
|
115
|
+
dist/something-else.js
|
|
129
116
|
```
|
|
130
|
-
|
|
131
|
-
|
|
117
|
+
We can use `entryFilter` to filter the entry files. For example, we should remove `vendor.js` and `something-else.js` if they are not in our coverage scope.
|
|
118
|
+
```
|
|
119
|
+
dist/main.js
|
|
120
|
+
```
|
|
121
|
+
When inline or linked sourcemap exists to the entry file, the source files will be extracted from the sourcemap for the entry file, and the entry file will be removed if `logging` is not `debug`.
|
|
122
|
+
```
|
|
123
|
+
> src/index.js
|
|
124
|
+
> src/components/app.js
|
|
125
|
+
> node_modules/dependency/dist/dependency.js
|
|
126
|
+
```
|
|
127
|
+
We can use `sourceFilter` to filter the source files. For example, we should remove `dependency.js` if it is not in our coverage scope.
|
|
128
|
+
```
|
|
129
|
+
> src/index.js
|
|
130
|
+
> src/components/app.js
|
|
131
|
+
```
|
|
132
|
+
Example:
|
|
132
133
|
```js
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const coverageResults = await coverageReport.generate();
|
|
138
|
-
console.log(coverageResults.summary);
|
|
134
|
+
const coverageOptions = {
|
|
135
|
+
entryFilter: (entry) => entry.url.indexOf("main.js") !== -1,
|
|
136
|
+
sourceFilter: (sourcePath) => sourcePath.search(/src\//) !== -1
|
|
137
|
+
};
|
|
139
138
|
```
|
|
140
139
|
|
|
141
140
|
## onEnd Hook
|
|
@@ -170,6 +169,7 @@ const coverageOptions = {
|
|
|
170
169
|
```
|
|
171
170
|
|
|
172
171
|
## `mcr` CLI
|
|
172
|
+
> The CLI will run the program as a [child process](https://nodejs.org/docs/latest/api/child_process.html) with `NODE_V8_COVERAGE=dir` until it exits gracefully, and generate the coverage report with the coverage data from the `dir`.
|
|
173
173
|
- Global mode
|
|
174
174
|
```sh
|
|
175
175
|
npm i monocart-coverage-reports -g
|
|
@@ -201,7 +201,7 @@ Options:
|
|
|
201
201
|
--lcov generate lcov.info file
|
|
202
202
|
-h, --help display help for command
|
|
203
203
|
```
|
|
204
|
-
- Using configuration file for more options
|
|
204
|
+
- Using configuration file for more [options](#default-options)
|
|
205
205
|
```sh
|
|
206
206
|
mcr "node ./test/test-node-env.js" -c test/cli-options.js
|
|
207
207
|
```
|
|
@@ -234,139 +234,103 @@ mcr "node ./test/test-node-env.js" -c test/cli-options.js
|
|
|
234
234
|
## Collecting Istanbul Coverage Data
|
|
235
235
|
- Instrumenting source code
|
|
236
236
|
> Before collecting Istanbul coverage data, It requires your source code is instrumented with Istanbul
|
|
237
|
-
-
|
|
238
|
-
-
|
|
239
|
-
-
|
|
237
|
+
- webpack: [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul), example: [webpack.config-istanbul.js](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/webpack.config-istanbul.js)
|
|
238
|
+
- rollup: [rollup-plugin-istanbul](https://github.com/artberri/rollup-plugin-istanbul)
|
|
239
|
+
- vite: [vite-plugin-istanbul](https://github.com/ifaxity/vite-plugin-istanbul)
|
|
240
240
|
- Browser
|
|
241
|
-
|
|
241
|
+
- Collecting coverage data from `window.__coverage__`, example: [test-istanbul.js](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/test-istanbul.js)
|
|
242
242
|
- Node.js
|
|
243
|
-
|
|
243
|
+
- Collecting coverage data from `global.__coverage__`
|
|
244
244
|
|
|
245
245
|
## Collecting V8 Coverage Data
|
|
246
246
|
- For source code: enable `sourcemap` and do not compress/minify:
|
|
247
|
-
-
|
|
248
|
-
-
|
|
249
|
-
-
|
|
247
|
+
- [webpack](https://webpack.js.org/configuration/): `devtool: source-map` and `mode: development`, example [webpack.config-v8.js](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/webpack.config-v8.js)
|
|
248
|
+
- [rollup](https://rollupjs.org/configuration-options/): `sourcemap: true`
|
|
249
|
+
- [vite](https://vitejs.dev/config/build-options.html): `sourcemap: true` and `minify: false`
|
|
250
|
+
- [esbuild](https://esbuild.github.io/api/): `sourcemap: true` and `minify: false`
|
|
250
251
|
- Browser (Chromium Only)
|
|
251
|
-
> Collecting coverage data with [Chromium Coverage API](#chromium-coverage-api)
|
|
252
|
+
> Collecting coverage data with [Chromium Coverage API](#chromium-coverage-api):
|
|
253
|
+
- [Playwright example](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/test-v8.js), and [anonymous](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/test-anonymous.js), [css](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/test-css.js)
|
|
254
|
+
- [Puppeteer example](https://github.com/cenfun/monocart-coverage-reports/blob/main/test/test-puppeteer.js)
|
|
252
255
|
- Node.js
|
|
253
|
-
|
|
256
|
+
- see following [Node.js V8 Coverage Report for Server Side](#nodejs-v8-coverage-report-for-server-side)
|
|
254
257
|
|
|
255
258
|
|
|
256
259
|
## Node.js V8 Coverage Report for Server Side
|
|
257
260
|
Possible solutions:
|
|
258
|
-
-
|
|
259
|
-
-
|
|
260
|
-
- Read the
|
|
261
|
-
-
|
|
261
|
+
- [NODE_V8_COVERAGE](https://nodejs.org/docs/latest/api/cli.html#node_v8_coveragedir)=`dir`
|
|
262
|
+
- Sets Node.js env `NODE_V8_COVERAGE`=`dir` before the program running, the coverage data will be saved to the `dir` after the program exits gracefully.
|
|
263
|
+
- Read the JSON file(s) from the `dir` and generate coverage report.
|
|
264
|
+
- Example:
|
|
262
265
|
> cross-env NODE_V8_COVERAGE=`.temp/v8-coverage-env` node [./test/test-node-env.js](./test/test-node-env.js) && node [./test/generate-node-report.js](./test/generate-node-report.js)
|
|
263
266
|
|
|
264
267
|
- [V8](https://nodejs.org/docs/latest/api/v8.html#v8takecoverage) API + NODE_V8_COVERAGE
|
|
265
|
-
- Writing the coverage started by NODE_V8_COVERAGE to disk on demand with `v8.takeCoverage()
|
|
266
|
-
-
|
|
268
|
+
- Writing the coverage started by NODE_V8_COVERAGE to disk on demand with `v8.takeCoverage()`, it does not require waiting until the program exits gracefully.
|
|
269
|
+
- Example:
|
|
267
270
|
> cross-env NODE_V8_COVERAGE=`.temp/v8-coverage-api` node [./test/test-node-api.js](./test/test-node-api.js)
|
|
268
271
|
|
|
269
|
-
- [Inspector](https://nodejs.org/docs/latest/api/inspector.html) API
|
|
272
|
+
- [Inspector](https://nodejs.org/docs/latest/api/inspector.html) API
|
|
270
273
|
- Connecting to the V8 inspector and enable V8 coverage.
|
|
271
|
-
- Taking coverage data and adding to the report
|
|
272
|
-
-
|
|
274
|
+
- Taking coverage data and adding it to the report.
|
|
275
|
+
- Example:
|
|
276
|
+
> node [./test/test-node-ins.js](./test/test-node-ins.js)
|
|
273
277
|
|
|
274
278
|
- [CDP](https://chromedevtools.github.io/devtools-protocol/) API
|
|
275
|
-
- Enabling [Node Debugging](https://nodejs.org/en/guides/debugging-getting-started/)
|
|
279
|
+
- Enabling [Node Debugging](https://nodejs.org/en/guides/debugging-getting-started/).
|
|
276
280
|
- Collecting coverage data with CDP API.
|
|
277
|
-
-
|
|
281
|
+
- Example:
|
|
282
|
+
> node --inspect=9229 [./test/test-node-cdp.js](./test/test-node-cdp.js)
|
|
278
283
|
|
|
279
|
-
- [
|
|
280
|
-
|
|
281
|
-
-
|
|
284
|
+
- [Node Debugging](https://nodejs.org/en/guides/debugging-getting-started) + CDP + NODE_V8_COVERAGE + V8 API
|
|
285
|
+
- When the program starts a server, it will not exit on its own, thus requiring a manual invocation of the `v8.takeCoverage()` interface to manually collect coverage data. Remote invocation of the `v8.takeCoverage()` interface can be accomplished through the `Runtime.evaluate` of the CDP.
|
|
286
|
+
- Example for [koa](https://github.com/koajs/koa) web server:
|
|
282
287
|
> node [./test/test-node-koa.js](./test/test-node-koa.js)
|
|
283
288
|
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
```
|
|
291
|
-
We can use `entryFilter` to filter the entry files. For example, we should remove `vendor.js` and `something-else.js` if they are not in our coverage scope.
|
|
292
|
-
```
|
|
293
|
-
dist/main.js
|
|
294
|
-
```
|
|
295
|
-
When inline or linked sourcemap exists to the entry file, the source files will be extracted from the sourcemap for the entry file, and the entry file will be removed if `logging` is not `debug`.
|
|
296
|
-
```
|
|
297
|
-
> src/index.js
|
|
298
|
-
> src/components/app.js
|
|
299
|
-
> node_modules/dependency/dist/dependency.js
|
|
300
|
-
```
|
|
301
|
-
We can use `sourceFilter` to filter the source files. For example, we should remove `dependency.js` if it is not in our coverage scope.
|
|
302
|
-
```
|
|
303
|
-
> src/index.js
|
|
304
|
-
> src/components/app.js
|
|
305
|
-
```
|
|
306
|
-
Example:
|
|
289
|
+
- [Child Process](https://nodejs.org/docs/latest/api/child_process.html) + NODE_V8_COVERAGE
|
|
290
|
+
- see [`mcr` CLI](#mcr-cli)
|
|
291
|
+
|
|
292
|
+
## Multiprocessing Support
|
|
293
|
+
The data will be added to `[outputDir]/.cache`, and the cache will be removed after reports generated.
|
|
294
|
+
- sub process 1
|
|
307
295
|
```js
|
|
308
|
-
const
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
296
|
+
const MCR = require('monocart-coverage-reports');
|
|
297
|
+
const options = require('path-to/same-options.js');
|
|
298
|
+
const coverageReport = MCR(options);
|
|
299
|
+
await coverageReport.add(coverageData1);
|
|
312
300
|
```
|
|
313
301
|
|
|
314
|
-
|
|
315
|
-
### Using [v8-to-istanbul](https://github.com/istanbuljs/v8-to-istanbul)
|
|
316
|
-
It is a popular library which is used to convert V8 coverage format to istanbul's coverage format. Most test frameworks are using it, such as [Jest](https://github.com/jestjs/jest/), [Vitest](https://github.com/vitest-dev/vitest), but it has two major problems:
|
|
317
|
-
- 1, The source mapping does not work well if the position is between the two consecutive mappings. for example:
|
|
302
|
+
- sub process 2
|
|
318
303
|
```js
|
|
319
|
-
const
|
|
320
|
-
|
|
321
|
-
|
|
304
|
+
const MCR = require('monocart-coverage-reports');
|
|
305
|
+
const options = require('path-to/same-options.js');
|
|
306
|
+
const coverageReport = MCR(options);
|
|
307
|
+
await coverageReport.add(coverageData2);
|
|
322
308
|
```
|
|
323
|
-
> `m1` and `m2` are two consecutive mappings, `p` is the position we looking for. However, we can only get the position of the `m1` if we don't fix it to `p`. Especially the generated code is different from the original code, such as minified, compressed or converted, then it becomes very difficult to find the middle position between two mappings.
|
|
324
309
|
|
|
325
|
-
-
|
|
326
|
-
And also there are some problems about counting the functions and branches:
|
|
310
|
+
- main process
|
|
327
311
|
```js
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
// v8-to-istanbul: new CovFunction()
|
|
335
|
-
// Problem: no anonymous function
|
|
336
|
-
}
|
|
337
|
-
} else if (block.functionName) {
|
|
338
|
-
// v8-to-istanbul: new CovFunction()
|
|
339
|
-
// Problem: no anonymous function
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
// Problem: When the function or parent-level function is uncovered, then its sub-level functions will never be counted.
|
|
312
|
+
// after all sub processes finished
|
|
313
|
+
const MCR = require('monocart-coverage-reports');
|
|
314
|
+
const options = require('path-to/same-options.js');
|
|
315
|
+
const coverageReport = MCR(options);
|
|
316
|
+
const coverageResults = await coverageReport.generate();
|
|
317
|
+
console.log(coverageResults.summary);
|
|
344
318
|
```
|
|
345
|
-
see source code [v8-to-istanbul.js](https://github.com/istanbuljs/v8-to-istanbul/blob/master/lib/v8-to-istanbul.js)
|
|
346
|
-
|
|
347
|
-
### How Monocart Works
|
|
348
|
-
We have removed `v8-to-istanbul` because of the two major problems and implemented new converter:
|
|
349
|
-
- 1, Trying to fix the middle position if not found the exact mapping.
|
|
350
|
-
- 2, Finding all functions and branches by parsing the source code [AST](https://github.com/acornjs/acorn), however the V8 cannot provide effective branch coverage information, so the branches is still not perfect.
|
|
351
319
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
| ConditionalExpression | ✔ Not Perfect |
|
|
356
|
-
| IfStatement | ✔ Not Perfect |
|
|
357
|
-
| LogicalExpression | ✔ Not Perfect |
|
|
358
|
-
| SwitchStatement | ✔ Not Perfect |
|
|
320
|
+
## Integration
|
|
321
|
+
- [monocart-reporter](https://cenfun.github.io/monocart-reporter/) - Test reporter for [Playwright](https://github.com/microsoft/playwright)
|
|
322
|
+
- [vitest-monocart-coverage](https://github.com/cenfun/vitest-monocart-coverage) - Integration with [Vitest](https://github.com/vitest-dev/vitest) coverage
|
|
359
323
|
|
|
360
324
|
## Ignoring Uncovered Codes
|
|
361
325
|
To ignore codes, use the special comment which starts with `v8 ignore `:
|
|
362
|
-
-
|
|
326
|
+
- Ignoring all until stop
|
|
363
327
|
```js
|
|
364
328
|
/* v8 ignore start */
|
|
365
329
|
function uncovered() {
|
|
366
330
|
}
|
|
367
331
|
/* v8 ignore stop */
|
|
368
332
|
```
|
|
369
|
-
-
|
|
333
|
+
- Ignoring the next line or next N lines
|
|
370
334
|
```js
|
|
371
335
|
/* v8 ignore next */
|
|
372
336
|
const os = platform === 'wind32' ? 'Windows' : 'Other';
|
|
@@ -448,6 +412,52 @@ const rawV8CoverageData = jsCoverage.map((it) => {
|
|
|
448
412
|
```
|
|
449
413
|
see example: [./test/test-puppeteer.js](./test/test-puppeteer.js)
|
|
450
414
|
|
|
415
|
+
## How to convert V8 to Istanbul
|
|
416
|
+
### Using [v8-to-istanbul](https://github.com/istanbuljs/v8-to-istanbul)
|
|
417
|
+
It is a popular library which is used to convert V8 coverage format to istanbul's coverage format. Most test frameworks are using it, such as [Jest](https://github.com/jestjs/jest/), [Vitest](https://github.com/vitest-dev/vitest), but it has two major problems:
|
|
418
|
+
- 1, The source mapping does not work well if the position is between the two consecutive mappings. for example:
|
|
419
|
+
```js
|
|
420
|
+
const a = tf ? 'true' : 'false';
|
|
421
|
+
^ ^ ^
|
|
422
|
+
m1 p m2
|
|
423
|
+
```
|
|
424
|
+
> `m1` and `m2` are two consecutive mappings, `p` is the position we looking for. However, we can only get the position of the `m1` or `m2` if we don't fix it to `p`. Especially the generated code is different from the original code, such as the code was minified, compressed or converted, it is difficult to find the exact position.
|
|
425
|
+
|
|
426
|
+
- 2, The coverage of functions and branches is incorrect. V8 only provided coverage at functions and it's blocks. But if a function is uncovered (count = 0), there is no information for it's blocks and sub-level functions.
|
|
427
|
+
And also there are some problems about counting the functions and branches:
|
|
428
|
+
```js
|
|
429
|
+
// Problem: When the function or parent-level function is uncovered, then its sub-level functions will never be counted.
|
|
430
|
+
functions.forEach(block => {
|
|
431
|
+
block.ranges.forEach((range, i) => {
|
|
432
|
+
if (block.isBlockCoverage) {
|
|
433
|
+
// v8-to-istanbul: new CovBranch()
|
|
434
|
+
// Problem: not every block is branch, and the first block could be function.
|
|
435
|
+
if (block.functionName && i === 0) {
|
|
436
|
+
// v8-to-istanbul: new CovFunction()
|
|
437
|
+
// Problem: no anonymous function
|
|
438
|
+
}
|
|
439
|
+
} else if (block.functionName) {
|
|
440
|
+
// v8-to-istanbul: new CovFunction()
|
|
441
|
+
// Problem: no anonymous function
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
```
|
|
446
|
+
see source code [v8-to-istanbul.js](https://github.com/istanbuljs/v8-to-istanbul/blob/master/lib/v8-to-istanbul.js)
|
|
447
|
+
|
|
448
|
+
### How Monocart Works
|
|
449
|
+
We implemented new converter instead of v8-to-istanbul:
|
|
450
|
+
- 1, Trying to fix the middle position if not found the exact mapping for the position.
|
|
451
|
+
- 2, Finding all functions and branches by parsing the source code [AST](https://github.com/acornjs/acorn), however the V8 cannot provide effective branch coverage information, so the branches is still not perfect but close to reality.
|
|
452
|
+
|
|
453
|
+
| AST | V8 |
|
|
454
|
+
| :---------------------| :------------- |
|
|
455
|
+
| AssignmentPattern | 🛇 Not Support |
|
|
456
|
+
| ConditionalExpression | ✔ Not Perfect |
|
|
457
|
+
| IfStatement | ✔ Not Perfect |
|
|
458
|
+
| LogicalExpression | ✔ Not Perfect |
|
|
459
|
+
| SwitchStatement | ✔ Not Perfect |
|
|
460
|
+
|
|
451
461
|
## Istanbul Introduction
|
|
452
462
|
- [Istanbul coverage report](https://istanbul.js.org/) - Instrumenting source codes and generating coverage reports
|
|
453
463
|
- [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul)
|
package/lib/utils/source-path.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
const { fileURLToPath } = require('url');
|
|
2
|
+
const { fileURLToPath, pathToFileURL } = require('url');
|
|
3
3
|
const Util = require('./util.js');
|
|
4
4
|
|
|
5
5
|
const resolveUrl = (input) => {
|
|
@@ -36,7 +36,7 @@ const getSourcePath = (url, index = '', type = '') => {
|
|
|
36
36
|
|
|
37
37
|
if (!url) {
|
|
38
38
|
// anonymous scripts will have __playwright_evaluation_script__ as their URL.
|
|
39
|
-
url = ['
|
|
39
|
+
url = pathToFileURL(['anonymous', index ? `-${index}` : '', type ? `.${type}` : ''].join('')).toString();
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
if (url.startsWith('file:')) {
|