Chai unittesting – expect(42).to.be.an(‘integer’)

A bit late, but for people coming from search engines, here is another solution:

var expect = require('chai').expect

expect(foo).to.be.a('number')
expect(foo % 1).to.equal(0)

The number check is required because of things such as true % 1 === 0 or null % 1 === 0.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)