Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Quick reference for the chaijs.com assertion library
/*
run this JavaScript on the chai API doc page:
console.log([].map.call(document.querySelectorAll('div.api_method_wrapper h3'), (x) => x.innerText).join('\n'))
*/
assert(expression, message)
.fail(actual, expected, [message], [operator])
.isOk(object, [message])
.isNotOk(object, [message])
.equal(actual, expected, [message])
.notEqual(actual, expected, [message])
.strictEqual(actual, expected, [message])
.notStrictEqual(actual, expected, [message])
.deepEqual(actual, expected, [message])
.notDeepEqual(actual, expected, [message])
.isAbove(valueToCheck, valueToBeAbove, [message])
.isAtLeast(valueToCheck, valueToBeAtLeast, [message])
.isBelow(valueToCheck, valueToBeBelow, [message])
.isAtMost(valueToCheck, valueToBeAtMost, [message])
.isTrue(value, [message])
.isNotTrue(value, [message])
.isFalse(value, [message])
.isNotFalse(value, [message])
.isNull(value, [message])
.isNotNull(value, [message])
.isNaN
.isNotNaN
.isUndefined(value, [message])
.isDefined(value, [message])
.isFunction(value, [message])
.isNotFunction(value, [message])
.isObject(value, [message])
.isNotObject(value, [message])
.isArray(value, [message])
.isNotArray(value, [message])
.isString(value, [message])
.isNotString(value, [message])
.isNumber(value, [message])
.isNotNumber(value, [message])
.isBoolean(value, [message])
.isNotBoolean(value, [message])
.typeOf(value, name, [message])
.notTypeOf(value, name, [message])
.instanceOf(object, constructor, [message])
.notInstanceOf(object, constructor, [message])
.include(haystack, needle, [message])
.notInclude(haystack, needle, [message])
.match(value, regexp, [message])
.notMatch(value, regexp, [message])
.property(object, property, [message])
.notProperty(object, property, [message])
.deepProperty(object, property, [message])
.notDeepProperty(object, property, [message])
.propertyVal(object, property, value, [message])
.propertyNotVal(object, property, value, [message])
.deepPropertyVal(object, property, value, [message])
.deepPropertyNotVal(object, property, value, [message])
.lengthOf(object, length, [message])
.throws(function, [constructor/string/regexp], [string/regexp], [message])
.doesNotThrow(function, [constructor/regexp], [message])
.operator(val1, operator, val2, [message])
.closeTo(actual, expected, delta, [message])
.approximately(actual, expected, delta, [message])
.sameMembers(set1, set2, [message])
.sameDeepMembers(set1, set2, [message])
.includeMembers(superset, subset, [message])
.includeDeepMembers(superset, subset, [message])
.oneOf(inList, list, [message])
.changes(function, object, property)
.doesNotChange(function, object, property)
.increases(function, object, property)
.doesNotIncrease(function, object, property)
.decreases(function, object, property)
.doesNotDecrease(function, object, property)
.ifError(object)
.isExtensible(object)
.isNotExtensible(object)
.isSealed(object)
.isNotSealed(object)
.isFrozen(object)
.isNotFrozen(object)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.