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

Replace assertRevert with expectRevert #14

@andrewgordstewart

Description

@andrewgordstewart

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions