-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: apply source-maps to test errors #884
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of iffys that I wasn't sure of, but aside from that LGTM
packages/build/package.json
Outdated
"posttest": "npm run lint" | ||
}, | ||
"devDependencies": { | ||
"fs-extra": "^5.0.0" | ||
"fs-extra": "^5.0.0", | ||
"source-map-support": "^0.5.2" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since source-map-support
is TypeScript specific, there's no need for it in build
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well build
is using the same shared mocha.opts
that TypeScript projects are using.
If we don't want to have source-map-support
as part of build's mocha opts, then we would have to create (and maintain) another copy, one without --require source-map-support
.
Not a big deal, I don't really mind either way.
packages/cli/package.json
Outdated
@@ -33,6 +33,7 @@ | |||
"nsp": "^3.1.0", | |||
"rimraf": "^2.6.2", | |||
"sinon": "^4.1.2", | |||
"source-map-support": "^0.5.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And same reply as above applies here too 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 to @shimks ' feedback, other than that, LGTM
Thank you for your review. I reworked
See 254cbc0 LGTY now? @kjdelisle @shimks |
packages/build/mocha.js.opts
Outdated
--recursive | ||
--exit | ||
--reporter dot | ||
--require source-map-support/register |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for this here right?
@bajtos Good catch. Is it possible to only add |
Do you think we need to fix https://github.com/strongloop/loopback-next/blob/master/packages/cli/generators/project/templates/test/mocha.opts too? |
I confirm it's good enough to only add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please only add source-map-support
as a dev dep of loopback-next/package.json
.
It seems that
Please note
I tried different config of nyc but none of them helped. |
Good point, I'll remove |
Good catch, will fix. |
I looked into this issue, I believe it's a known problem of https://github.com/istanbuljs/nyc#accurate-stack-traces-using-source-maps
IIUC, AFAICT, the current |
254cbc0
to
65cf212
Compare
@raymondfeng I addressed your comments in 65cf212, PTAL. |
When we got rid of ts-node in #602, we also unintentionally dropped the code modifying error stack traces to point to original TypeScript sources instead of the transpiled JavaScript output. As a result, assertion failures contained stack traces pointing to code that we are not familiar with, which made troubleshooing difficult. This commits add source-map-support as a global dev-dependency plus a dev-dependency of example repositories that must work outside of our monorepo too. The single shared `mocha.opts` was split into two different options files: - `mocha.ts.opts` which registers source-map support - `mocha.js.opts` with no support for source maps
9994cf6
to
9da5f48
Compare
This is a follow-up to #884. The changes make it impossible to run 'npm test' for individual packages. - There is no local mocha command for each package and it depends on the global installation of 'mocha' - With the global mocha, --require source-map-support/register cannot be resolved. The PR adds 'lb-mocha' command so that we can support source-map-support correctly along with other options. No global mocha installation is needed.
This is a follow-up to #884. The changes make it impossible to run 'npm test' for individual packages. - There is no local mocha command for each package and it depends on the global installation of 'mocha' - With the global mocha, --require source-map-support/register cannot be resolved. The PR adds 'lb-mocha' command so that we can support source-map-support correctly along with other options. No global mocha installation is needed.
This is a follow-up to #884. The changes make it impossible to run 'npm test' for individual packages. - There is no local mocha command for each package and it depends on the global installation of 'mocha' - With the global mocha, --require source-map-support/register cannot be resolved. The PR adds 'lb-mocha' command so that we can support source-map-support correctly along with other options. No global mocha installation is needed.
This is a follow-up to #884. The changes make it impossible to run 'npm test' for individual packages. - There is no local mocha command for each package and it depends on the global installation of 'mocha' - With the global mocha, --require source-map-support/register cannot be resolved. The PR adds 'lb-mocha' command so that we can support source-map-support correctly along with other options. No global mocha installation is needed.
This is a follow-up to #884. The changes make it impossible to run 'npm test' for individual packages. - There is no local mocha command for each package and it depends on the global installation of 'mocha' - With the global mocha, --require source-map-support/register cannot be resolved. The PR adds 'lb-mocha' command so that we can support source-map-support correctly along with other options. No global mocha installation is needed.
When we got rid of ts-node in #602, we also unintentionally dropped
the code modifying error stack traces to point to original TypeScript
sources instead of the transpiled JavaScript output.
As a result, assertion failures contained stack traces pointing to code
that we are not familiar with, which made troubleshooing difficult.
This commits add source-map-support as a dependency of our projects
and modifies shared
mocha.opts
to register it at runtime.Checklist
npm test
passes on your machinepackages/cli
were updatedpackages/example-*
were updated