diff --git a/doc/api/cli.md b/doc/api/cli.md index 31e554024285ff..8a1ca4893a8b69 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -1110,9 +1110,19 @@ variable is strongly discouraged. ### `NODE_V8_COVERAGE=dir` -When set, Node.js will begin outputting [V8 JavaScript code coverage][] to the -directory provided as an argument. Coverage is output as an array of -[ScriptCoverage][] objects: +When set, Node.js will begin outputting [V8 JavaScript code coverage][] and +[Source Map][] data to the directory provided as an argument (coverage +information is written as JSON to files with a `coverage` prefix). + +`NODE_V8_COVERAGE` will automatically propagate to subprocesses, making it +easier to instrument applications that call the `child_process.spawn()` family +of functions. `NODE_V8_COVERAGE` can be set to an empty string, to prevent +propagation. + +#### Coverage Output + +Coverage is output as an array of [ScriptCoverage][] objects on the top-level +key `result`: ```json { @@ -1126,13 +1136,46 @@ directory provided as an argument. Coverage is output as an array of } ``` -`NODE_V8_COVERAGE` will automatically propagate to subprocesses, making it -easier to instrument applications that call the `child_process.spawn()` family -of functions. `NODE_V8_COVERAGE` can be set to an empty string, to prevent -propagation. +#### Source Map Cache + +> Stability: 1 - Experimental + +If found, Source Map data is appended to the top-level key `source-map-cache` +on the JSON coverage object. + +`source-map-cache` is an object with keys representing the files source maps +were extracted from, and the values include the raw source-map URL +(in the key `url`) and the parsed Source Map V3 information (in the key `data`). -At this time coverage is only collected in the main thread and will not be -output for code executed by worker threads. +```json +{ + "result": [ + { + "scriptId": "68", + "url": "file:///absolute/path/to/source.js", + "functions": [] + } + ], + "source-map-cache": { + "file:///absolute/path/to/source.js": { + "url": "./path-to-map.json", + "data": { + "version": 3, + "sources": [ + "file:///absolute/path/to/original.js" + ], + "names": [ + "Foo", + "console", + "info" + ], + "mappings": "MAAMA,IACJC,YAAaC", + "sourceRoot": "./" + } + } + } +} +``` ### `OPENSSL_CONF=file`