Meteor-Community-Packages / meteor-mocha

A Mocha test driver package for Meteor 1.3+. This package reports server AND client test results in the server console and can be used for running tests on a CI server or locally.
https://packosphere.com/meteortesting/mocha
MIT License
67 stars 40 forks source link

Line lines reported are not mapped back to original code #84

Closed mitar closed 4 years ago

mitar commented 5 years ago

Assertion like this:

I20181123-20:01:35.867(-8)?       AssertionError: expected { Object (type, content) } to deeply equal { Object (type, content) }
I20181123-20:01:35.868(-8)?       + expected - actual
I20181123-20:01:35.868(-8)? 
I20181123-20:01:35.868(-8)?            }
I20181123-20:01:35.869(-8)?            {
I20181123-20:01:35.869(-8)?              \"content\": [
I20181123-20:01:35.869(-8)?                {
I20181123-20:01:35.869(-8)?       -          \"text\": \"Test\"
I20181123-20:01:35.870(-8)?       +          \"text\": \"Test.\"
I20181123-20:01:35.870(-8)?                  \"type\": \"text\"
I20181123-20:01:35.870(-8)?                }
I20181123-20:01:35.870(-8)?              ]
I20181123-20:01:35.871(-8)?              \"type\": \"paragraph\"
I20181123-20:01:35.871(-8)?       
I20181123-20:01:35.871(-8)?       at Function.assert.deepEqual (packages/modules.js?hash=8cacc4b932a2fbbf2a33b8b74deabd9750c7c386:63680:32)
I20181123-20:01:35.871(-8)?       at Context._callee7$ (app/app.js?hash=3ad9fc511699e599f88739f3e613e310ca2e11c8:8758:24)
I20181123-20:01:35.871(-8)?       at tryCatch (packages/modules.js?hash=8cacc4b932a2fbbf2a33b8b74deabd9750c7c386:58690:40)
I20181123-20:01:35.872(-8)?       at Generator.invoke [as _invoke] (packages/modules.js?hash=8cacc4b932a2fbbf2a33b8b74deabd9750c7c386:58924:22)
I20181123-20:01:35.872(-8)?       at Generator.prototype.(anonymous function) [as next] (packages/modules.js?hash=8cacc4b932a2fbbf2a33b8b74deabd9750c7c386:58742:21)
I20181123-20:01:35.872(-8)?       at tryCatch (packages/modules.js?hash=8cacc4b932a2fbbf2a33b8b74deabd9750c7c386:58690:40)
I20181123-20:01:35.872(-8)?       at invoke (packages/modules.js?hash=8cacc4b932a2fbbf2a33b8b74deabd9750c7c386:58780:20)
I20181123-20:01:35.873(-8)?       at http://localhost:3100/packages/modules.js?hash=8cacc4b932a2fbbf2a33b8b74deabd9750c7c386:58790:13
I20181123-20:01:35.873(-8)?       at http://localhost:3100/packages/meteor.js?hash=c9a34f92f28ede5a42eac467d3fa1763b624436a:1168:22

Is not very useful. Because of babel and my using of async code, there is no way to really discover which assert failed in the code from:

app/app.js?hash=3ad9fc511699e599f88739f3e613e310ca2e11c8:8758:24

I would hope that this gets mapped to original source code locations.

I am using meteortesting:mocha@1.0.1.

SimonSimCity commented 5 years ago

This problem is less related to this plugin but rather to how Meteor is handling the code. You'll get a similar call-stack when your Meteor app crashes.

Just some ideas to get further on ... Does this only apply to client-side or also to server-side code? Would using this plugin already help you? https://www.npmjs.com/package/source-map-support

mitar commented 5 years ago

Generally Meteor is pretty good at mapping back to lines, even for exceptions it shows. So I am not sure where this is breaking here?

I think this is something MDG could give some insight how to do or how they are doing? cc @benjamn

SimonSimCity commented 5 years ago

I looked into it a bit more and found out that puppeteer (or also any other browser I've been looking into) does not apply source maps to the stack traces. https://github.com/GoogleChrome/puppeteer/issues/985

If you ask me, this looks like a browser related problem. Until now I was not really successful in applying the proposed solutions like https://github.com/novocaine/sourcemapped-stacktrace or https://github.com/evanw/node-source-map-support.

It would maybe the right place to ask Meteor to add support for this. Another way would be if you'd write a reporter yourself which prints out the native exception to the console so the browser transforms the stack.

SimonSimCity commented 4 years ago

Closing because it's off-topic for this package. This package just takes whatever the console of the browser reports and forwards it to the command-line. If the stack-trace is not how you'd like to have it, please report this on the repository of the meteor framework.