Skip to content

Migrate chai and assert usages to jest expect #7476

Description

@danez

We currently - now after jest has been landed in #7455 - have a mix of different assertion methods in tests.

  • There is chai in use.
  • There is assert in use.
  • There is jests expect in use.

The first two should be removed and rewritten to make use of expect which comes with jest.

so for example

-import chai from "chai";
-import assert from "assert";
-
-chai.expect(actualCode).to.be.equal("var fn;");
+expect(actualCode).toBe("var fn;")
-assert.strictEqual(this.constructor, Bar);
+expect(this.constructor).toBe(Bar)

The jest matchers should be used as good as possible, so for example not expect(x >= 3).toBe(true) but instead expect(x).toBeGreaterThanOrEqual(3)

The doc of jests matchers is here: https://facebook.github.io/jest/docs/en/expect.html

As we have a lot of tests split up in a lot of packages this task can also be split up and only one/some package(s) at a time be migrated.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions