So nyc is mangling my files as follows:
  at _onCreate (src/post/admin.js:1:10453)
  at doQuery (src/db.js:59:216)
  at process._tickCallback (internal/process/next_tick.js:68:7)
I am unsure of how to use a source map to unmangle this. The docs state:
Accurate stack traces using source-maps.
When produce-source-map is set to true, then the instrumented source files will include inline source maps for the instrumenter transform. When combined with source-map-support, stack traces for instrumented code will reflect their original lines.
So I tried the following npm run command:
"NODE_ENV=test nyc mocha --require ./tests/setup.js --require source-map-support/register --produce-source-map true --bail ./tests/unit/$FILE"
combined with the nyc setting:
"nyc": {
    "include": [
        "src"
    ],
    "exclude": [
        "./tmp/**/*",
        "./tests"
    ],
    "instrument": true,
    "report-dir": "./tests/coverage",
    "temp-dir": "./tests/temp",
    "source-map": true,
    "produce-source-map": true
}
but the line is still mangled.
the basic pre-condition for it to work would be (as described here):
npm install --save-dev source-map-support
make sure nyc is ^10.3.2 (10.3.0 was broken).
"devDependencies": {
    ...
    "mocha": "^3.3.0",
    "nyc": "^10.3.2",
    "source-map-support": "^0.4.15",
}
the nyc config should be "sourceMap": true, "produce-source-map": true.
and the documentation explains how to use them:
CLI Usage
node -r source-map-support/register compiled.js
Programmatic Usage
Put the following line at the top of the compiled file.
require('source-map-support').install();
one can also define mapping file-names by adding comments:
//# sourceMappingURL=filename.js.map
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With