-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add --parallel
, --bail
and --grep
params to the test task
#2359
Conversation
🦋 Changeset detectedLatest commit: 7a6d522 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
--parallel
flag to test task--parallel
, --bail
and --grep
params to the test task
const mochaConfig: MochaOptions = { | ||
...config.mocha, | ||
bail, | ||
grep, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should/do we allow these to be configured in config.mocha
as well? If so, this would overwrite them (i.e. if they were set in config.mocha
but not passed as params to the subtask).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I hadn't noticed that, thanks for pointing it out. I actually think that would be the correct behavior though? Normally CLI flags override what's in the config (for example, that's what Prettier does by default). But it's good to know that this is the case. I will add a comment explaining that this is intentional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait I see what you mean. For the grep
flag this works correctly, but bail
has a default value, and so it will always override whatever is in the config. I'll fix this, thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch! I was also tricked by this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
docs/guides/waffle-testing.md
Outdated
@@ -125,6 +125,23 @@ expect(await greeter.greet()).to.equal("Hola, mundo!"); | |||
|
|||
We can modify the state of a contract in the same way we read from it. Calling `setGreeting` will set a new greeting message. After the `Promise` is resolved, we perform another assertion to verify that the greeting change took effect. | |||
|
|||
### Running tests in parallel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd move this to its own guide, to make it more visible.
Also, this is not a waffle thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
As discussed offline, this PR looks great, but we should test that the params actually enable those features. @fvictorio suggested using a fixture project for that. |
Co-authored-by: F. Eugene Aumson <feuGeneA@users.noreply.github.com>
Co-authored-by: F. Eugene Aumson <feuGeneA@users.noreply.github.com>
49dc2d2
to
fe479e0
Compare
Co-authored-by: Patricio Palladino <email@patriciopalladino.com>
Co-authored-by: Patricio Palladino <email@patriciopalladino.com>
a41bb6a
to
36411fd
Compare
@alcuadrado this is ready for review. |
Blocked by this. The obvious solution is to update our stack traces to not have circular references, but there might be other approaches. |
We could do something like this. |
SolidityError instances cannot be JSON.stringified because they contain circular references. This causes an issue with parallel tests, because mocha tries to serialize errors thrown by tests. This commit changes the SourceReference interface to prevent these circular references.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LFG!
Add support for the
--parallel
,--bail
and--grep
flags in the test task.The first commit is just the mocha upgrades, the second one adds the
--parallel
flag. Notice that this flag also addshardhat/register
to Mocha's required files. This makes parallel tests mostly work out-of-the-box, but there might be a risk here that I'm not seeing.Pending stuff:
hardhat-gas-reporter
andsolidity-coverage
work on parallel mode. Document how to make them work if not, or just document the limitation if making them work is too much effort.--bail
and--grep
flags