Skip to content
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

Webpack source maps #272

Closed
rovansteen opened this issue Jun 10, 2016 · 3 comments
Closed

Webpack source maps #272

rovansteen opened this issue Jun 10, 2016 · 3 comments

Comments

@rovansteen
Copy link

I am struggling to get NYC working with a combination of webpack, mocha & mocha-webpack. Right now I am getting a test coverage report from NYC but that's just one compiled file. According to the documentation the source map should be inline so I did that with webpack but unfortunately I still see the compiled file in the test report.

Is this approach even possible, and if so what am I doing wrong here?

@bcoe
Copy link
Member

bcoe commented Jun 10, 2016

@JaKXz can you provide any feedback on this, I know you were attempting a similar setup.

@reauv we're having some luck hooking into source-maps using an alternate instrumenter, discussed here: #268

@JaKXz
Copy link
Member

JaKXz commented Jun 10, 2016

Hi @reauv, I have indeed attempted a similar setup: ATM and AFAIK, webpack is not compatible with nyc because nyc looks at all the files that are required in your tests to instrument them, whereas webpack loads them into a bundle runs things differently. See #176 or #229.

If possible, I'd suggest running your tests directly with mocha and using ts-node. Here's an example from a project I'm working on: https://github.com/JaKXz/typescript-react-redux-starter/tree/749a0f22b7dce6781b9e52c3c95e089effbde810

The only thing that example is missing is the ability to instrument --all files, because there's an esprima error from trying to transpile the TS code for nyc to look at that gets thrown that I haven't had time to look further into. If you're just using ES2015+, you should just be able to do nyc --all --require babel-register mocha [assuming you have your ./test/mocha.opts file configured correctly]. Hope that helps!

@bcoe bcoe closed this as completed Jun 13, 2016
@rovansteen
Copy link
Author

Thanks for the responses. I am not using TS, so I am not sure if that's going to help me. I ended up switching to a setup with Karma & Isparta, because that works with webpack. I kinda need webpack because otherwise I have to rewrite all my imports because I extensively use webpack's resolve settings. Thanks anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants