-
-
Notifications
You must be signed in to change notification settings - Fork 360
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
Include certain node modules #833
Comments
It seems to be possible to include files from every folder expect node_modules. Problem seems to be inside nyc: node_moduls/nyc/test-exclude/index.js line 126 and 133 in nyc version 11.8.0. By default nyc excludes everything inside node_modules and files from node_modules can not be included. Sadly explicit includes do not overwrite implicit excludes. BAD Workaround: Maybe a better workaround: |
Hi @pingynator ! Did you find a better solution for that work around? |
Hey @antoniocascais :) I tried some other workaround without using nyc. I am using a webpack-based solution. I have written my "own" webpack-plugin, which is pretty much the webpack-mocha-plugin. It should be possible though to "rewrite" nyc and deploy your "own" nyc to your node_modules. Mocha is generating a json-object which you can manipulate. This object is the source for the report-files (f.e. html-report). So you can inject you own report data there, too. Although I would suggest not to do this. |
Hi @pingynator. Thanks for the response! For now we also came up with a workaround (which was forking NYC and remove the logic to exclude the node_modules), but we don't want to have this as a final solution. We will keep digging and try to solve the problem in a proper way... Thansk for the help! Your comment from 30th of May was really helpful in understanding why the coverage was not working properly 👍 |
Hey @antoniocascais. I am glad you found a solution. If you find a "proper way" to solve the problem I would be really happy to hear about it. :) |
Hi @pingynator ! We found a proper solution for our problem! So, for a bit of context: We had a NodeJs project with the following dir tree: --node_modules (the one for 3rd party libs) We had our own code under our own When we found your post explaining why the files are not evaluated for the code coverage, we decided to rename our node_modules folder. After trying every solution that we found on google, the final one was having sub-modules. We now have: In the main package.json we declare the dependencies for the other package.jsons:
In app/package.json we declare the dependency for app/service:
And the services/package.json and the lib/package.json are just simple files without dependencies:
By doing This solution worked perfectly in our local machines, but then we had problems when deploying the code to CloudFoundry (which is the service that we use): for some reason that I still don't understand, the symlinks are ignored. So, the required files in the code were not found and the application wouldn't start. We tried several approaches to solve this issue and we ended up writing a script that removes the folders with symlinks from So now we have a clean (in our opinion) solution for our local development and a not-so-clean solution for deploying the application. Hope this helps and if you have any question please feel free to ask! 😄 |
This release contains a number of fixes which will make it easier to instrument some/all of node_modules - #912 and #977 in particular apply to this issue. |
Is there a way to include some of the files in the node_modules folder? I'm using a .nycrc file as:
But files in the /node_modules/microservicebus-core/lib/ are not covered:
The text was updated successfully, but these errors were encountered: