Skip to content
New issue

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

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

Already on GitHub? # to your account

Allow passing mocha params in hardhat test command #4307

Open
jmendiola222 opened this issue Aug 16, 2023 · 2 comments
Open

Allow passing mocha params in hardhat test command #4307

jmendiola222 opened this issue Aug 16, 2023 · 2 comments
Labels
status:blocked Blocked by other issues or external reasons type:feature Feature request

Comments

@jmendiola222
Copy link

Describe the feature

There's been many requests for supporting particular params to mocha, either by config file and specially command. But most of them where stale closed, I think there is good evidence of this being useful on a variety of cases:

#1116
#2572
#2502
#2316
#1242
etc

My particular case, is the inability of using --invert while doing a --grep filter.

> hardhat test  --grep /.*CI.*/i --invert

Error HH305: Unrecognized param --invert

Refs: https://mochajs.org/api/mocha#invert

Search terms

mocha params test invert grep arguments

@fvictorio
Copy link
Member

Hi @jmendiola222, thanks for this. You are right that this would be extremely useful. The problem is that, the way Hardhat's argument parser works right now, we need to add a new specific param for each Mocha param we want to support.

I think the best way to do this would be to first have support for -- in our tasks. I opened #4314 to track that. If we had that, then we could support something like this:

hh test -- --grep foo --invert

And the test task wouldn't need to explicitly support the invert flag.

@fvictorio fvictorio added status:blocked Blocked by other issues or external reasons type:feature Feature request and removed status:triaging labels Aug 21, 2023
@jmendiola222
Copy link
Author

I'm not into the internals of hardhat implementation, so I can't tell if your proposal is in fact the best approach, but it certainly sounds reasonable. Thanks.

smoelius added a commit to trailofbits/necessist that referenced this issue Nov 30, 2024
To allow Necessist to work with Mocha tests ending in `(`...`)`.

This is a bandaid. A better approach would be to disable printing of
times altogether. However, this appears to be an open issue for Hardhat:

- NomicFoundation/hardhat#4307
- NomicFoundation/hardhat#4314
github-merge-queue bot pushed a commit to trailofbits/necessist that referenced this issue Dec 1, 2024
To allow Necessist to work with Mocha tests ending in `(`...`)`.

This is a bandaid. A better approach would be to disable printing of
times altogether. However, this appears to be an open issue for Hardhat:

- NomicFoundation/hardhat#4307
- NomicFoundation/hardhat#4314
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
status:blocked Blocked by other issues or external reasons type:feature Feature request
Projects
Status: Backlog
Development

No branches or pull requests

3 participants