BDD Assertions Flashcards

These chainers are available for BDD assertions (expect/should). Aliases listed can be used interchangeably with their original chainer. (43 cards)

1
Q

not

A

expect(name).to.not.equal(‘Jane’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

deep

A

expect(obj).to.deep.equal({ name: ‘Jane’ })

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

nested

A

expect({a: {b: [‘x’, ‘y’]}}).to.have.nested.property(‘a.b[1]’)
expect({a: {b: [‘x’, ‘y’]}}).to.nested.include({‘a.b[1]’: ‘y’})

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

ordered

A

expect([1, 2]).to.have.ordered.members([1, 2]).but.not.have.ordered.members([2, 1])

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

any

A

expect(arr).to.have.any.keys(‘name’, ‘age’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

all

A

expect(arr).to.have.all.keys(‘name’, ‘age’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

a(type)

A

expect(‘test’).to.be.a(‘string’)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

include(value)

A

expect([1,2,3]).to.include(2)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

ok

A

expect(undefined).to.not.be.ok

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

true

A

expect(true).to.be.true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

false

A

expect(false).to.be.false

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

null

A

expect(null).to.be.null

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

undefined

A

expect(undefined).to.be.undefined

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

exist

A

expect(myVar).to.exist

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

empty

A

expect([]).to.be.empty

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

arguments

A

expect(arguments).to.be.arguments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

equal(value)

A

expect(42).to.equal(42)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

deep.equal(value)

A

expect({ name: ‘Jane’ }).to.deep.equal({ name: ‘Jane’ })

19
Q

eql(value)

A

expect({ name: ‘Jane’ }).to.eql({ name: ‘Jane’ })

20
Q

greaterThen(value)

A

expect(10).to.be.greaterThan(5)

21
Q

least(value)

A

expect(10).to.be.at.least(10)

22
Q

lessThan(value)

A

expect(5).to.be.lessThan(10)

23
Q

most(value)

A

expect(‘test’).to.have.length.of.at.most(4)

24
Q

within(start, finish)

A

expect(7).to.be.within(5,10)

25
instanceOf(constructor)
expect([1, 2, 3]).to.be.instanceOf(Array)
26
property(name, [value])
expect(obj).to.have.property('name')
27
deep.property(name, [value])
expect(deepObj).to.have.deep.property('tests[1]', 'e2e')
28
ownProperty(name)
expect('test').to.have.ownProperty('length')
29
ownPropertyDescriptor(name)
expect({a: 1}).to.have.ownPropertyDescriptor('a')
30
lengthOf(value)
expect('test').to.have.lengthOf(3)
31
match(RegExp)
expect('testing').to.match(/^test/)
32
string(string)
expect('testing').to.have.string('test')
33
key(key1, [key2], […])
expect({ pass: 1, fail: 2 }).to.have.key('pass')
34
throw(constructor)
expect(fn).to.throw(Error)
35
respondTo(method)
expect(obj).to.respondTo('getName')
36
itself
expect(Foo).itself.to.respondTo('bar')
37
satisfy(method)
expect(1).to.satisfy((num) => { return num > 0 })
38
closeTo(expected, delta)
expect(1.5).to.be.closeTo(1, 0.5)
39
members(set)
expect([1, 2, 3]).to.include.members([3, 2])
40
oneOf(values)
expect(2).to.be.oneOf([1,2,3])
41
change(function)
expect(fn).to.change(obj, 'val')
42
increase(function)
expect(fn).to.increase(obj, 'val')
43
decrease(function)
expect(fn).to.decrease(obj, 'val')