Error if solcoverjs passed but nonexistent (#889)

pull/893/head
area 5 months ago committed by GitHub
parent 04d178eedd
commit adaeb54230
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  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