You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I understand if you're not interested in supporting this use case, but I thought I'd ask. I have a codebase that's bundled with webpack and we utilize aliases and modulesDirectories and whatnot that sorta break the rules of CommonJS. Also, some of these files depend on DOM globals (like getComputedStyle for example) that are not exposed in the node environment in which we're running our tests.
While we work out what to do about these things, we'd still like to get code coverage reporting on those files. However, using the --all flag makes things fail because of what I mentioned above.
So is there a chance that we could make files required by the --all flag ignore errors. I've successfully implemented this myself by adding a single test:
/* * This file's purpose is to require all the files * to make sure that everything we care to track * coverage for is instrumented. */importtestfrom'ava'import{resolve}from'path'importglobfrom'glob'constbadPaths=['app.js','App.js','__tests__','vendor/',]constglobToCover=resolve(__dirname,'../..')+'/js/**/*.js'constfilesToCover=glob.sync(globToCover).filter((filepath)=>{returnbadPaths.every((file)=>!filepath.includes(file))})filesToCover.forEach((file)=>{try{require(file)}catch(error){// ignore the error.// our purposes of getting the file// insturmented for coverage have been accomplished// by simply requiring the file.// if you're curious, you could log out the filename// here to see which files break CommonJS rules or// depend on browser globals :-)}})test('covered files',t=>{// if we don't have any filesToCover, then something's probably wrong...t.notSame(filesToCover.length,0)})
This works out pretty well, but I'd love to have this just built into how --all works. Thoughts 💭
The text was updated successfully, but these errors were encountered:
The module needs to execute so the Istanbul instrumentation can track it. I wonder if Istanbul should wrap everything in a try/catch so in can report modules that fail to run. Alternatively nyc could catch the error. Not sure if it could still include it in the coverage report or if this needs warning output.
I understand if you're not interested in supporting this use case, but I thought I'd ask. I have a codebase that's bundled with webpack and we utilize
aliases
andmodulesDirectories
and whatnot that sorta break the rules of CommonJS. Also, some of these files depend on DOM globals (likegetComputedStyle
for example) that are not exposed in the node environment in which we're running our tests.While we work out what to do about these things, we'd still like to get code coverage reporting on those files. However, using the
--all
flag makes things fail because of what I mentioned above.So is there a chance that we could make files required by the
--all
flag ignore errors. I've successfully implemented this myself by adding a single test:This works out pretty well, but I'd love to have this just built into how
--all
works. Thoughts 💭The text was updated successfully, but these errors were encountered: