Skip to content

Commit

Permalink
Error if solcoverjs passed but nonexistent (#889)
Browse files Browse the repository at this point in the history
  • Loading branch information
area authored Jul 4, 2024
1 parent 04d178e commit adaeb54
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plugins/resources/plugin.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ function loadSolcoverJS(config={}){
throw new Error(error)
}

// Config is optional
// Config is optional, but if passed and not found, error
} else if (config.solcoverjs) {
const message = ui.generate('solcoverjs-fail') + " --solcoverjs flag was set but no file was found";
throw new Error(message);
} else {
coverageConfig = {};
}
Expand Down
20 changes: 20 additions & 0 deletions test/integration/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@ describe('Hardhat Plugin: error cases', function() {
verify.coverageNotGenerated(hardhatConfig);
})

it('.solcover.js is not found', async function(){
const taskArgs = {
solcoverjs: "./file-that-does-not-exist.js"
}

mock.install('Simple', 'simple.js', solcoverConfig);
mock.hardhatSetupEnv(this);

try {
await this.env.run("coverage", taskArgs);
assert.fail()
} catch (err) {
assert(
err.message.includes('--solcoverjs flag was set but no file was found'),
`Should error if --solcoverjs passed but not found: ${err.message}`
);
}
})


it('.solcover.js has incorrectly formatted option', async function(){
solcoverConfig.port = "Antwerpen";

Expand Down

0 comments on commit adaeb54

Please sign in to comment.