-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathdeno_test.deno.txt
180 lines (136 loc) · 8.32 KB
/
deno_test.deno.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
┏━━━━━━━━━━━━━━━┓
┃ DENO_TEST ┃
┗━━━━━━━━━━━━━━━┛
ALTERNATIVES ==> #See Mocha
VERSION ==> #See Deno
ASSERTIONS ==> #See deno assertions
DIFF TESTING ==> #See deno snapshots
GENERIC MOCKING ==> #See deno mock
TIMERS MOCKING ==> #See deno time
TEST COVERAGE ==> #See deno coverage
TYPESCRIPT TESTS TESTING ==> #See deno test types
BENCHMARKS ==> #See deno bench
testing/bdd #BDD. std library
node:test #Can be used instead of Deno libraries
┌──────────┐
│ TEST │
└──────────┘
Deno.test(['TITLE', ] #Top-level test
[TOPTS, ][FUNC(T)[->>]]) #'TITLE' is TOPTS.name (def: FUNC.name)
#FUNC is TOPTS.fn
BDD.test|it(...) #Like Deno.test(...)
TOPTS|T.name #'TITLE'
TOPTS.fn #FUNC(T)[->>]
TEST FAILURE ==> #Throwing an ERROR. Prints its ERROR.message|stack normally
T.step(...)->>BOOL #Nested test. Same arguments as Deno.test(...) except must use either TOPTS or 'TITLE'|FUNC
#>BOOL awaits nested test completion and returns whether it failed
# - must be awaited
# - can be used to parallelize, but only if TOPTS.sanitize* false
T.parent #T2. Only with nested tests.
BDD.describe(...)->SUITE #Like Deno.test(...) except only for parent tests.
#Tests declared within FUNC() are automatically children:
# - they do not return >BOOL
# - no parent T
BDD.it|describe(SUITE, ...)
TOPTS.suite #Parent SUITE, even if not within SUITE's FUNC(), to avoid identation
T.origin #import.meta.url of top-level test file
┌───────────────────┐
│ ORCHESTRATION │
└───────────────────┘
TOPTS.before|afterAll|Each #FUNC()[->>] run before|after all|each test of the SUITE
#Only with describe(...)
BDD.beforeEach|afterEach
BDD.before[All]|after[All] #Same for all tests for all files
this #T. Only with it|before*|after*(...)
┌────────────┐
│ CONFIG │
└────────────┘
--[no-]config|-c CONF_FILE #See Deno doc
┌───────────────┐
│ SELECTION │
└───────────────┘
deno test [UPATH|DIR...] #Run tests.
[-- ARG...] #If DIR, use DIR/**/[..._|.]test.EXT or DIR/**/__tests__/**/*.EXT, with EXT js[x]|mjs|ts[x]|mts
#Def DIR: '.'
#ARG... are passed as Deno.args
--permit-no-files #Exit code 0 if no test files found. Only when targetting DIRs
--ignore=PATH,... #Ignore files. Only for ones targetted from DIRs
CONFIG.exclude
CONFIG.test.include|exclude #'UPATH|DIR_GLOB'_ARR to include|exclude
--no-run #Only cache files, do not run tests
--filter=GLOB|/REGEXP/ #Filter by test 'TITLE'
#Only targets top-level tests 'TITLE', which also include their children
TOPTS.ignore #BOOL (def: false). Exclude test
Deno.test.ignore(...)
BDD.it|test|describe
.ignore|skip(...) #Same
TOPTS.only #BOOL (def: false). Only include this test
#Not with nested tests.
Deno.test.only(...)
BDD.it|test|describe.only(...) #Same but works on nested tests.
┌───────────────┐
│ EXECUTION │
└───────────────┘
--fail-fast[=NUM] #Stop after NUM (def: 1) test failure
--watch
--no-clear-screen #See Deno doc
ENVVAR DENO_SLOW_TEST_TIMEOUT=NUM #Every NUM secs (def: 60), print a message if a long test is still running
┌───────────┐
│ DEBUG │
└───────────┘
--inspect[-brk|wait][=HOSTNAME] #See Deno doc
┌─────────────────┐
│ ENVIRONMENT │
└─────────────────┘
--unstable-*
--quiet|-q
--v8-flags
--seed=NUM
--location=URL
--import-map=IMPORT_MAP_FILE
--no-remote
--cached-only
--reload|-r
--no-npm
--[no-]node-modules-dir[=DIR]
--unsafely-ignore-certificate
-errors[=HOSTNAME,...]
--cert #See Deno doc
--allow-*
--no-prompt #See Deno doc
TOPTS.permissions #Like WORKER OPTS.deno.permissions
#Not with nested tests.
TOPTS.sanitizeExit #If true (def), process exits fail test instead
TOPTS.sanitizeResources #If true (def), fail test if it opens an I/O resource without closing it
TOPTS.sanitizeOps #If true (def), fail test if it starts an OP or microtask without awaiting it
@std/testing/unstable-bdd !#
configureGlobalSanitizers(OPTS) #OPTS: sanitize* BOOL, to set TOPTS.sanitize*
┌───────────────┐
│ REPORTING │
└───────────────┘
--reporter=REPORTER #Among:
# - 'pretty' (def): based on TAP, but prettified
# - 'tap'
# - 'dot'
# - 'junit'
#On stdout
--junit-path=PATH #
--hide-stacktraces #Do not print ERROR stack traces
┌─────────────────┐
│ PARALLELISM │
└─────────────────┘
--parallel #Run test files in parallel. Def: serial
#Tests within a file are always serial, unless using Promise.all() on child tests
#Test files all run in same process, whether parallel|serial
ENVVAR DENO_JOBS #NUM of parallel files at once with --parallel. Def: NUM of CPUs
--shuffle[=NUM] #Shuffle the order in which the tests are run. NUM is seed.
#Reason: catch dependencies between tests
┌───────────┐
│ JSDOC │
└───────────┘
--doc #Runs ```js[x]|ts[x] code blocks in JSDoc|Markdown
#Those can contain assertions
┌────────────────┐
│ TYPESCRIPT │
└────────────────┘
--[no-]check[=STR] #See Deno doc