Chai to Jest

JavaScript pattern

Convert Chai test assertions to Jest.


Apply with the Grit CLI
grit apply chai_to_jest

Convert assertions

BEFORE
describe('sum', () => {
  it('should work for positive numbers', () => {
    const object = { nine: 9 };
    expect(object).contains({ nine: 9 });
    assert.equal(1 + 2, 3, '1 plus 2 is 3');
  }).timeout(1000);
});
AFTER
describe('sum', () => {
  it('should work for positive numbers', () => {
    const object = { nine: 9 };
    expect(object).toMatchObject({ nine: 9 });
    expect(1 + 2).toEqual(3);
  }).timeout(1000);
});