avajs / typescript

Test TypeScript projects using AVA.
MIT License
73 stars 16 forks source link

Document how to use source map support #20

Open novemberborn opened 4 years ago

novemberborn commented 4 years ago

This provider doesn't translate error stack traces using source maps. We should document how you can set that up yourself, by installing source-map-support and adding source-map-support/register to AVA's require configuration.

jonsadka commented 4 years ago

@novemberborn happy to help document but the steps I've taken thus far don't seem to have changed anything.

After configuring per the README.md, I took your comment to mean:

  1. yarn add source-map-support
  2. Adding this one line to ava.config.js
    {
    "ava": {
      require: ['source-map-support/register'],
    }
    }

Further discussion

Assuming that we can get the above steps to work, what does source-map-support do beyond what TypeScript already does by adding "sourceMap": true, to the tsconfig.json?

If we building before running Ava, we should be getting the source maps we need, no?

"scripts": {
  "test": "tsc --build tsconfig.tests.json && nyc ava"
}
jonsadka commented 4 years ago

By chance, I tried running ava without nyc which gets source maps working. 🎉

Seems like the problem is related to issues with nyc that others have reported (https://github.com/avajs/ava/issues/1604 -> https://github.com/istanbuljs/nyc/issues/619) and not the TypeScript plugin.

novemberborn commented 4 years ago

Assuming that we can get the above steps to work, what does source-map-support do beyond what TypeScript already does by adding "sourceMap": true, to the tsconfig.json?

It rewrites stack traces, taking the source map into account.

By chance, I tried running ava without nyc which gets source maps working. 🎉

Seems like the problem is related to issues with nyc that others have reported (avajs/ava#1604 -> istanbuljs/nyc#619) and not the TypeScript plugin.

Yea… this stuff gets complicated fast. nyc transforms the compiled TypeScript to add instrumentation, and probably attempts to rewrite stack traces to hide its work. But now the code that is executing is two transforms away from your source.