BDD Assertions Flashcards

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

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
Q

instanceOf(constructor)

A

expect([1, 2, 3]).to.be.instanceOf(Array)

26
Q

property(name, [value])

A

expect(obj).to.have.property(‘name’)

27
Q

deep.property(name, [value])

A

expect(deepObj).to.have.deep.property(‘tests[1]’, ‘e2e’)

28
Q

ownProperty(name)

A

expect(‘test’).to.have.ownProperty(‘length’)

29
Q

ownPropertyDescriptor(name)

A

expect({a: 1}).to.have.ownPropertyDescriptor(‘a’)

30
Q

lengthOf(value)

A

expect(‘test’).to.have.lengthOf(3)

31
Q

match(RegExp)

A

expect(‘testing’).to.match(/^test/)

32
Q

string(string)

A

expect(‘testing’).to.have.string(‘test’)

33
Q

key(key1, [key2], […])

A

expect({ pass: 1, fail: 2 }).to.have.key(‘pass’)

34
Q

throw(constructor)

A

expect(fn).to.throw(Error)

35
Q

respondTo(method)

A

expect(obj).to.respondTo(‘getName’)

36
Q

itself

A

expect(Foo).itself.to.respondTo(‘bar’)

37
Q

satisfy(method)

A

expect(1).to.satisfy((num) => { return num > 0 })

38
Q

closeTo(expected, delta)

A

expect(1.5).to.be.closeTo(1, 0.5)

39
Q

members(set)

A

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

40
Q

oneOf(values)

A

expect(2).to.be.oneOf([1,2,3])

41
Q

change(function)

A

expect(fn).to.change(obj, ‘val’)

42
Q

increase(function)

A

expect(fn).to.increase(obj, ‘val’)

43
Q

decrease(function)

A

expect(fn).to.decrease(obj, ‘val’)