a simple chai plugin for js type assertions
npm install chai-asserttype
const chai = require('chai');
const asserttype = require('chai-asserttype');
chai.use(asserttype);
Asserts that type of actual
is Number.
expect(1).to.be.number();
expect(0).to.be.number();
expect(-1).to.be.number();
expect(63465789908753).to.be.number();
expect(27.11).to.be.number();
Asserts that type of actual
is String.
expect('').to.be.string();
expect('foobar').to.be.string();
Asserts that type of actual
is Boolean.
expect(true).to.be.boolean();
expect(false).to.be.boolean();
Asserts that type of actual
is Object.
expect({}).to.be.object();
Asserts that type of actual
is Array.
expect([]).to.be.array();
expect([1, 2, 3]).to.be.array();
Asserts that type of actual
is date.
expect(new Date()).to.be.date();
Asserts that type of actual
is Function.
expect(() => true).to.be.function();