Skip to content
This repository has been archived by the owner on Nov 7, 2019. It is now read-only.

Replace assertRevert with expectRevert #14

Open
andrewgordstewart opened this issue Feb 6, 2019 · 0 comments
Open

Replace assertRevert with expectRevert #14

andrewgordstewart opened this issue Feb 6, 2019 · 0 comments

Comments

@andrewgordstewart
Copy link
Contributor

Related: magmo/apps#162

The assertRevert function uses chai assertions, and does not block test success until the promise resolves, forcing the user to add a delay after the assertion.

The following expectRevert blocks jest tests until the promise returned by fn resolves, which is far superior:

async function expectRevert(fn, msg) {
  expect.assertions(1);
  await expect(fn()).rejects.toThrowError(msg);
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant