Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error if --solcoverjs passed but file is nonexistent #889

Merged
merged 1 commit into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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