Saturday, 27 October 2018

node - how to use source-map with nyc and mocha

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.



from node - how to use source-map with nyc and mocha

No comments:

Post a Comment