Error if solcoverjs passed but nonexistent

solcoverjs-exists-check
Alex Rea 5 months ago
parent 04d178eedd
commit b9e4677bc0
  1. 5
      plugins/resources/plugin.utils.js
  2. 20
      test/integration/errors.js

@ -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 = {};
}

@ -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";

Loading…
Cancel
Save