-
Notifications
You must be signed in to change notification settings - Fork 16
/
ava_assertions.node_cli.txt
132 lines (91 loc) · 7.14 KB
/
ava_assertions.node_cli.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
AVA_ASSERTIONS
ALTERNATIVES ==> #See chai doc
VERSION ==> #Part of Ava (see its doc)
/=+===============================+=\
/ : : \
)==: COMMON :==(
\ :_______________________________: /
\=+===============================+=/
EXCEPTIONS ==> #Assertions only report: they do not throw (i.e. control flow continues)
#However following exceptions are handled silently, i.e. it's just like if assertions were throwing
CONF.failWithoutAssertions #BOOL (def: true): fail tests with no assertions
OTHER ASSERTION LIBRARY ==> #Can use other assertion library (e.g. core Node.js assert)
#However CONF.failWithoutAssertions must be false
#Also recognizes `expect` and `chai`
TEST.*(..., 'ASSERT_TITLE') #For any assertion.
->BOOL #Def 'ASSERT_TITLE': none
#Is printed to console by default reporter
#BOOL is whether passed, which can be used as TypeScript type guard
TEST.*.skip(...) #For any assertion, skip it
/=+===============================+=\
/ : : \
)==: ENHANCEMENTS :==(
\ :_______________________________: /
\=+===============================+=/
CONF.compileEnhancements #BOOL (def: true).
#Automatically uses POWER-ASSERT (see its doc) with TEST.assert()
#Only with built-in assertion library
#TEST must be named t
STACK TRACES ==> #Stack trace are automatically cleaned (using both CLEAN-STACK and STACK-UTILS.clean(), see their doc)
#Also source maps are handled (using NODE-SOURCE-MAP-SUPPORT.install(), see its doc)
/=+===============================+=\
/ : : \
)==: DRY RUN :==(
\ :_______________________________: /
\=+===============================+=/
TEST.try(['TRY_TITLE', ]
FUNC(TEST2, ARGS...)[_ARR],
ARGS...)->PROMISE_ATTEMPT[_ARR] #Dry run all assertions inside FUNC()
ATTEMPT.commit([OPTS]) #Perform the assertions (no dry run)
#OPTS:
# - retainLogs BOOL (def: true): whether to print logs
ATTEMPT.discard([OPTS]) #Discard the ATTEMPT (i.e. was only dry run)
#OPTS: retainLogs BOOL (def: false)
ATTEMPT.title #'TRY_TITLE'
ATTEMPT.passed #BOOL
ATTEMPT.errors #ERROR_ARR
ATTEMPT.logs #STR_ARR. Assertions output.
/=+===============================+=\
/ : : \
)==: GENERIC :==(
\ :_______________________________: /
\=+===============================+=/
TEST.pass() #
TEST.fail() #
TEST.is|not(VAL, VAL2) #Object.is()
TEST.[not]deepEqual(VAL, VAL2) #Deep ==
TEST.like(VAL, VAL2) #Deep == or is subset
/=+===============================+=\
/ : : \
)==: BOOLEAN :==(
\ :_______________________________: /
\=+===============================+=/
TEST.truthy|falsy(VAL) #== true|false
TEST.true|false(VAL) #=== true|false
TEST.assert(VAL) #== true
/=+===============================+=\
/ : : \
)==: STRING :==(
\ :_______________________________: /
\=+===============================+=/
TEST.[not]regex(STR, REGEXP) #REGEXP.test()
/=+===============================+=\
/ : : \
)==: FUNCTION :==(
\ :_______________________________: /
\=+===============================+=/
TEST.throws(FUNC[, OBJ])->ERROR #FUNC() throws or rejects an ERROR matching OBJ:
# - instanceOf TYPE
# - name STR: ERROR.name
# - message STR|REGEXP|FUNC(STR)->BOOL: ERROR.message
# - is ERROR
# - code STR|NUM (ERROR.code)
TEST.notThrows(FUNC) #FUNC() does not throw nor reject
TEST.throwsAsync
(ASYNC_FUNC|PROMISE[, VAL])
->PROMISE2_ERROR #Must await return value
TEST.notThrowsAsync
(ASYNC_FUNC|PROMISE)
->PROMISE2_ERROR #Must await return value