Boolean
.toBeBoolean()
Use .toBeBoolean
when checking if a value is a Boolean
.
test('passes when value is a boolean', () => { expect(false).toBeBoolean(); expect(true).toBeBoolean(); expect(1 === 1).toBeBoolean(); expect(1).not.toBeBoolean(); });
Tests
.toBeTrue()
Use .toBeTrue
when checking a value is equal (===
) to true
.
const isJestCool = () => true; test('is jest cool', () => { expect(isJestCool()).toBeTrue(); expect(false).not.toBeTrue(); });
Tests
.toBeFalse()
Use .toBeFalse
when checking a value is equal (===
) to false
.
const areWeThereYet = () => false; test('returns false', () => { expect(areWeThereYet()).toBeFalse(); expect(true).not.toBeFalse(); });
Tests