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

Replace chai.should with chai.expect. #1687

Closed
nventuro opened this issue Mar 19, 2019 · 7 comments · Fixed by #1780
Closed

Replace chai.should with chai.expect. #1687

nventuro opened this issue Mar 19, 2019 · 7 comments · Fixed by #1780
Labels
good first issue Low hanging fruit for new contributors to get involved! tests Test suite and helpers.

Comments

@nventuro
Copy link
Contributor

Throughout the codebase we're using chai.should, which patches all objects so that they have the should property (this is done here).

It'd be great to get rid of that, and switch to expect, which is not only simpler due to it just requiring to import a function, but also has arguably clearer semantics (and prevents ugly hacks like (await promise()).should.bla.bla.bla). This conversion should be rather straightforward, with most obj.should.equal being replaced for expect(obj).to.equal, though we'd also have to add const { expect } = require('chai') at the top of the relevant files.

@nventuro nventuro added improvement tests Test suite and helpers. labels Mar 19, 2019
@frangio
Copy link
Contributor

frangio commented Mar 21, 2019

Can you explain what is an ugly hack about (await promise()).should.bla.bla.bla?

@nventuro
Copy link
Contributor Author

'Hack' isn't really the best name, but I dislike having to wrap the thing in parenthesis simply due to how await works (which is IMO a quirkiness of the language, which wouldn't happen if e.g. await was a function).

That said, I much prefer expect due to it being a verb, and allowing things like expectFailure, expectEvent, expectRevert, etc.

@ckshei
Copy link
Contributor

ckshei commented Apr 12, 2019

tagging this - I can work on this next

@ckshei
Copy link
Contributor

ckshei commented Apr 22, 2019

@nventuro I updated one of the tests and wanted to see if I was on the right track with what you were thinking. Could you look it over and let me know your thoughts?

#1723

@yopereir
Copy link
Contributor

yopereir commented May 28, 2019

I can work on this within a few days. Just had one doubt- do we need to import bignumber for whenever we use expect(obj).to.bignumber.equal(obj); ?

@nventuro
Copy link
Contributor Author

Awesome @RCYP! @ckshei had started working on this (#1723), but closed the issue due to a lack of time. We could merge intermediate work to a development branch, since this may end up being somewhat big.

Regarding bignumber, the plugin is automatically installed by openzeppelin-test-helpers, but we sometimes need to import BN to do things such as new BN(3). All in all, I don't think you'll need to touch any of these imports for your PR.

@frangio
Copy link
Contributor

frangio commented May 28, 2019

We could merge intermediate work to a development branch

Yes, let's move forward with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Low hanging fruit for new contributors to get involved! tests Test suite and helpers.
Projects
None yet
4 participants