-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
JavaScript Source Maps Support #550
Comments
+1 |
this shouldn't really have anything to do with Mocha, you can compile source maps for own code if you like |
I might be wrong about this, but what I see is that even though I compile source maps for my code (and I checked that these source maps really work), if an Exception is thrown, mocha reports only the bundle.js file which has the minified/concatenated code. |
Ashnur, you are rigth. Also problem with line numbers. |
that's not the concern of mocha though, you can compile source maps (or use sourceurl) if you're aggregating |
@visionmedia I am sorry, but I don't understand your response. I mean I understand the meaning of it, but it seems to me, that you just repeated your last response and have not reponded to me. That or I must be completely missing the point somewhere, and I am unaware of not just what it is, but where I am missing it. I am using mocha in the browser on a code which has to be browserified in order to work there. I use the browserify feature of compiling source maps for the code, and they work properly, as long as I am not trying to use the code with mocha. When I use it with mocha, the source maps go away, I only get the original file and line nr. references, not the source maps, which - I repeat the third time - are there. So please, if you do not mind taking the time, explain to me what else should I do so that I can use the compiled source maps with mocha? |
hmm I'm not sure why they would go away when using Mocha, maybe the browsers just don't respect source maps for |
that's my impression too... |
May I use mocha in this way |
@jacobbubu nope, if you use coffeescript you're screwed just about everywhere on the server-side for error mapping |
If anyone's still interested in source mapped stack traces, @evanw has recently added browser compatability (using browserify) to node-source-map-support here: evanw/node-source-map-support@70c343e Note that it relies on Error.prepareStackTrace which I believe is only paid attention to by Chrome, so source mapped stack traces only work there, but it's working a treat for me :) |
+1 Reading the comments above, I think there is some misunderstanding. My understanding of the original posters request is that Mocha's HTML output after running the tests contains stack traces which do not use source-maps. I use Coffeescript + source-maps which work pretty well with Chrome's developer tools, but they are ignored by Mocha. For anyone using Coffeescript or other javascript preprocessors, a stack trace of the generated javascript is not very helpful. My productivity would increase quite a bit if all stack traces Mocha outputs used source-maps, when available. |
I'm definitely against doing anything custom to pull in source maps, I don't see why the browser can't do this for you when the developer tools are open etc, pretty silly to force every client lib to handle this. |
Dirty hack to make it work with PhantomJS. May come in handy. |
+1. I realize from what @visionmedia replied that this necessarily isn't a direct Mocha issue but any more visibility into getting this working would be good. I test prod code with Mocha which means I test compressed code. If I can't see real line numbers in the errors it makes Mocha half as useful as it should be. |
I solved this problem with require('source-map-support').install();
describe('APIs', () => {
it('should do something', (done) => {
throw new Error();
///....
});
});
}); Now the stacktrace is pointing to the "correct" source file. I hope this will help you :-) |
@dreampulse This is great information. Care to post it in the wiki? |
Agree with @dreampulse
Otherwise, function |
@dreampulse +1 |
FYI - https://github.com/evanw/node-source-map-support#browser-support |
Maybe it's possible to use source maps for better "view source" and doc reporter when testing with minified JS or languages that compile to JS.
http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/
Thank you.
The text was updated successfully, but these errors were encountered: