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

Test setup helper added #1482

Merged
merged 36 commits into from
Dec 7, 2018
Merged

Test setup helper added #1482

merged 36 commits into from
Dec 7, 2018

Conversation

Aniket-Engg
Copy link
Contributor

@Aniket-Engg Aniket-Engg commented Oct 25, 2018

Fixes #1205

I have added the helper named as chai.js.
Used it in expectEvent and shouldFail helper.
Also tests who require expectEvent and shouldFail helper do not need to require chai modules again. I tested them in Ownable and PaymentSplitter tests.
If chai helper lives upto the expectation, I can work further on removing extra requires from other files of testing.

@nventuro nventuro added this to the Test helpers milestone Nov 29, 2018
@nventuro
Copy link
Contributor

Hello again @Aniket-Engg, thanks for working on this!

I wouldn't call that helper chai, that might be confuse our users into thinking we're hosting a local version of it. Maybe setup is enough?

Also, keep in mind that some tests need not only the should object to be exported, but also the BigNumber one (to create new instances, e.g. new BigNumber(3)), so we need to provide it (const { should, BigNumber } = require('setup')).

And finally, while it is true that we may be importing the same file multiple times (when also importing e.g. expectEvent), I still wouldn't remove the redundant imports, since it will be annoying down the line to figure out why chai isn't working if we ever move stuff around, remove the import from expectEvent, etc.: keeping everything explicit will reduce future pain :)

@Aniket-Engg
Copy link
Contributor Author

@nventuro I assume i got your words right. Have made changes accordingly, please review.

Copy link
Contributor

@nventuro nventuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Aniket-Engg, thanks for following up with this! Left a couple comments clarifying what I meant in my previous comment, but this looks almost ready :)

test/payment/PaymentSplitter.test.js Outdated Show resolved Hide resolved
test/helpers/setup.js Outdated Show resolved Hide resolved
@Aniket-Engg
Copy link
Contributor Author

@nventuro I think now this is ready to be implemented in other files. What you think?

Copy link
Contributor

@nventuro nventuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, I think we can add this everywhere now!

test/helpers/shouldFail.js Outdated Show resolved Hide resolved
@nventuro
Copy link
Contributor

nventuro commented Dec 7, 2018

Looks like the CI job wasn't triggered :/ This is rather weird, I'll look into it.

@nventuro
Copy link
Contributor

nventuro commented Dec 7, 2018

Seems like it was related to the PR not being mergeable - after creating a merge commit it is now working again.

Copy link
Contributor

@nventuro nventuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks a lot @Aniket-Engg! At first I thought a couple BigNumber exports were missing, but that was just because it was needed for chai-bignumber.

@nventuro nventuro merged commit 70fd243 into OpenZeppelin:master Dec 7, 2018
@Aniket-Engg Aniket-Engg deleted the fix/#1205 branch December 10, 2018 10:27
@Aniket-Engg
Copy link
Contributor Author

Yeah, i checked each file deeply. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants