Journal
Excluding a folder from VSCode’s search (and disabling Jest’s generated coverage reports)
A few weeks ago, I set up Jest’s coverage option in Cushion to keep me honest about testing. Coverage runs after my tests and alerts me of any lines of code that aren’t touched by the tests. While it doesn’t point out which tests I need to write, it at least provides a goal to strive for if coverage doesn’t return 100%. I absolutely love having coverage enabled. It gives me so much more confidence about my code.
The downside of coverage is that, by default, it generates a ton of files. These are the reporter files, which let you view your coverage in various formats (json, html, etc). These are easy enough to disable, which I realized after I thought about writing this post, so if you don’t want to generate these files, simply change Jest’s coverageReporters option to ["text", "text-summary"]
. This will only output the coverage in the Terminal without generating any files.
Before I learned this, these files kept showing up whenever I’d search for anything in VSCode. I put up with it for a few days, but tonight, I thought I’d take two seconds to fix it. A quick Google search led me to the search.exclude
setting, which is an array of glob keys and booleans. By default for my workspace, it excludes dependency folders, like node_modules
. To exclude the coverage files, I simply needed to add "**/coverage"
to this list. While that worked perfectly, I immediately realized I could simply disable coverage reports in Jest. Nevertheless, I thought it’d be worth sharing these tidbits.