Kyle Coberly
kylecoberly.com
Recall the 3 types of Chai particles
assert.equal(sum(1, 1), 2)
expect(sum(1, 1)).to.equal(2)
System's Perspective
User's Perspective
Works with any test runner
expect Particles
const people = [{ kyle: { name: "Kyle", height: 90 }, dusing: { name: "Dusing", height: 100 }, }] const tallestPerson = { name: "Dusing", height: 100 } expect(getTallest(people)).to.deep.equal(tallestPerson)
Chainer
Assertion
Flag
to, be
have, has
a, an
and, but
equal
property
true, false, ok, exist
empty
members, keys
include
lengthOf
not
deep
nested
ordered
expect(result).to.have.nested.property("key.nestedKey", "value") expect(result).to.include("some sub string") expect(result).to.have.keys(["key1", "key2"]) expect(result).to.have.all.members(["item 1", "item 2"]) expect(result).to.match(/[a-zA-Z]/)
expect(result).to.equal("some string") expect(result).to.deep.equal({ message: "some string" }) expect(result).to.not.equal("some string") expect(result).to.have.lengthOf(3)
Equality
Matching
By Kyle Coberly
Lightning talk for DenverScript 9/24/19