BDD Assertions Flashcards
These chainers are available for BDD assertions (expect/should). Aliases listed can be used interchangeably with their original chainer.
not
expect(name).to.not.equal(‘Jane’)
deep
expect(obj).to.deep.equal({ name: ‘Jane’ })
nested
expect({a: {b: [‘x’, ‘y’]}}).to.have.nested.property(‘a.b[1]’)
expect({a: {b: [‘x’, ‘y’]}}).to.nested.include({‘a.b[1]’: ‘y’})
ordered
expect([1, 2]).to.have.ordered.members([1, 2]).but.not.have.ordered.members([2, 1])
any
expect(arr).to.have.any.keys(‘name’, ‘age’)
all
expect(arr).to.have.all.keys(‘name’, ‘age’)
a(type)
expect(‘test’).to.be.a(‘string’)
include(value)
expect([1,2,3]).to.include(2)
ok
expect(undefined).to.not.be.ok
true
expect(true).to.be.true
false
expect(false).to.be.false
null
expect(null).to.be.null
undefined
expect(undefined).to.be.undefined
exist
expect(myVar).to.exist
empty
expect([]).to.be.empty
arguments
expect(arguments).to.be.arguments
equal(value)
expect(42).to.equal(42)