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…


This content originally appeared on Jonnie Hallman (@destroytoday) and was authored by Jonnie Hallman (@destroytoday)

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.

Reply via email


This content originally appeared on Jonnie Hallman (@destroytoday) and was authored by Jonnie Hallman (@destroytoday)


Print Share Comment Cite Upload Translate Updates
APA

Jonnie Hallman (@destroytoday) | Sciencx (2020-07-16T21:26:00+00:00) Excluding a folder from VSCode’s search (and disabling Jest’s generated coverage reports). Retrieved from https://www.scien.cx/2020/07/16/excluding-a-folder-from-vscodes-search-and-disabling-jests-generated-coverage-reports-2/

MLA
" » Excluding a folder from VSCode’s search (and disabling Jest’s generated coverage reports)." Jonnie Hallman (@destroytoday) | Sciencx - Thursday July 16, 2020, https://www.scien.cx/2020/07/16/excluding-a-folder-from-vscodes-search-and-disabling-jests-generated-coverage-reports-2/
HARVARD
Jonnie Hallman (@destroytoday) | Sciencx Thursday July 16, 2020 » Excluding a folder from VSCode’s search (and disabling Jest’s generated coverage reports)., viewed ,<https://www.scien.cx/2020/07/16/excluding-a-folder-from-vscodes-search-and-disabling-jests-generated-coverage-reports-2/>
VANCOUVER
Jonnie Hallman (@destroytoday) | Sciencx - » Excluding a folder from VSCode’s search (and disabling Jest’s generated coverage reports). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2020/07/16/excluding-a-folder-from-vscodes-search-and-disabling-jests-generated-coverage-reports-2/
CHICAGO
" » Excluding a folder from VSCode’s search (and disabling Jest’s generated coverage reports)." Jonnie Hallman (@destroytoday) | Sciencx - Accessed . https://www.scien.cx/2020/07/16/excluding-a-folder-from-vscodes-search-and-disabling-jests-generated-coverage-reports-2/
IEEE
" » Excluding a folder from VSCode’s search (and disabling Jest’s generated coverage reports)." Jonnie Hallman (@destroytoday) | Sciencx [Online]. Available: https://www.scien.cx/2020/07/16/excluding-a-folder-from-vscodes-search-and-disabling-jests-generated-coverage-reports-2/. [Accessed: ]
rf:citation
» Excluding a folder from VSCode’s search (and disabling Jest’s generated coverage reports) | Jonnie Hallman (@destroytoday) | Sciencx | https://www.scien.cx/2020/07/16/excluding-a-folder-from-vscodes-search-and-disabling-jests-generated-coverage-reports-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.