-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathtape-modern_assertions.javascript.txt
37 lines (27 loc) · 1.93 KB
/
tape-modern_assertions.javascript.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ TAPE-MODERN ASSERTIONS ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
ALTERNATIVES ==> #See chai doc
VERSION ==> #Part of tape-modern (see its doc)
┌────────────┐
│ COMMON │
└────────────┘
EXCEPTIONS ==> #Assertions only report: they do not throw (i.e. control flow continues)
#This helps reporting several failed assertions per test
#However this means following assertions might crash: they will be handled but might clutter
#test output (where only first failed assertion might be relevant)
assert #ASSERT
ASSERT.*(..., 'ASSERT_TITLE') #Can be last argument for any assertion. Def:
# - ASSERT.pass|fail(): undefined
# - others: 'should ...'
┌─────────────┐
│ GENERIC │
└─────────────┘
ASSERT.pass|fail() #
ASSERT.ok(VAL) #== true
ASSERT.equal(VAL) #===
┌──────────────┐
│ FUNCTION │
└──────────────┘
ASSERT.throws(FUNC,
TYPE|REGEXP|FUNC(ERROR)->BOOL) #Throw ERROR matching second argument