File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -222,7 +222,10 @@ function loadSolcoverJS(config={}){
222222 throw new Error ( error )
223223 }
224224
225- // Config is optional
225+ // Config is optional, but if passed and not found, error
226+ } else if ( config . solcoverjs ) {
227+ const message = ui . generate ( 'solcoverjs-fail' ) + " --solcoverjs flag was set but no file was found" ;
228+ throw new Error ( message ) ;
226229 } else {
227230 coverageConfig = { } ;
228231 }
Original file line number Diff line number Diff line change @@ -46,6 +46,26 @@ describe('Hardhat Plugin: error cases', function() {
4646 verify . coverageNotGenerated ( hardhatConfig ) ;
4747 } )
4848
49+ it ( '.solcover.js is not found' , async function ( ) {
50+ const taskArgs = {
51+ solcoverjs : "./file-that-does-not-exist.js"
52+ }
53+
54+ mock . install ( 'Simple' , 'simple.js' , solcoverConfig ) ;
55+ mock . hardhatSetupEnv ( this ) ;
56+
57+ try {
58+ await this . env . run ( "coverage" , taskArgs ) ;
59+ assert . fail ( )
60+ } catch ( err ) {
61+ assert (
62+ err . message . includes ( '--solcoverjs flag was set but no file was found' ) ,
63+ `Should error if --solcoverjs passed but not found: ${ err . message } `
64+ ) ;
65+ }
66+ } )
67+
68+
4969 it ( '.solcover.js has incorrectly formatted option' , async function ( ) {
5070 solcoverConfig . port = "Antwerpen" ;
5171
You can’t perform that action at this time.
0 commit comments