-
Notifications
You must be signed in to change notification settings - Fork 1
/
Ava.res
297 lines (279 loc) · 11.3 KB
/
Ava.res
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
module ThrowsExpectation = {
module Message = {
type t = string
external re: Js.Re.t => t = "%identity"
external fn: (~message: string => bool) => t = "%identity"
}
type t = {
message?: Message.t,
name?: string,
is?: Js.Exn.t,
code?: int,
instanceOf?: 'instanceOf. 'instanceOf,
}
}
module ExecutionContext = {
@live
type t<'context> = {
mutable context: 'context,
title: string,
passed: bool,
}
@send external plan: (t<'context>, int) => unit = "plan"
@send
external teardown: (t<'context>, unit => promise<unit>) => promise<unit> = "teardown"
@send external timeout: (t<'context>, float, ~message: string=?) => unit = "timeout"
module Skip = {
@send @scope("plan") external plan: (t<'context>, int) => unit = "skip"
@send @scope("teardown")
external teardown: (t<'context>, unit => promise<unit>) => promise<unit> = "skip"
@send @scope("timeout")
external timeout: (t<'context>, float, ~message: string=?) => unit = "skip"
}
}
@live
type meta = {
file: string,
snapshotDirectory: string,
}
@module("ava") @scope("default") external meta: meta = "meta"
@module("ava")
external test: (string, ExecutionContext.t<'context> => unit) => unit = "default"
@module("ava")
external asyncTest: (string, ExecutionContext.t<'context> => promise<unit>) => unit = "default"
@module("ava") @scope("default")
external todo: string => unit = "todo"
@module("ava") @scope("default")
external beforeEach: (ExecutionContext.t<'context> => unit) => unit = "beforeEach"
@module("ava") @scope("default")
external asyncBeforeEach: (ExecutionContext.t<'context> => promise<unit>) => unit = "beforeEach"
@module("ava") @scope("default")
external before: (ExecutionContext.t<'context> => unit) => unit = "before"
@module("ava") @scope("default")
external asyncBefore: (ExecutionContext.t<'context> => promise<unit>) => unit = "before"
@module("ava") @scope("default")
external afterEach: (ExecutionContext.t<'context> => unit) => unit = "afterEach"
@module("ava") @scope("default")
external asyncAfterEach: (ExecutionContext.t<'context> => promise<unit>) => unit = "afterEach"
@module("ava") @scope("default")
external after: (ExecutionContext.t<'context> => unit) => unit = "after"
@module("ava") @scope("default")
external asyncAfter: (ExecutionContext.t<'context> => promise<unit>) => unit = "after"
module Failing = {
@module("ava") @scope("default")
external test: (string, ExecutionContext.t<'context> => unit) => unit = "failing"
@module("ava") @scope("default")
external asyncTest: (string, ExecutionContext.t<'context> => promise<unit>) => unit = "failing"
@module("ava") @scope(("default", "failing"))
external only: (string, ExecutionContext.t<'context> => unit) => unit = "only"
@module("ava") @scope(("default", "failing"))
external asyncOnly: (string, ExecutionContext.t<'context> => promise<unit>) => unit = "only"
@module("ava") @scope(("default", "failing"))
external skip: (string, ExecutionContext.t<'context> => unit) => unit = "skip"
@module("ava") @scope(("default", "failing"))
external asyncSkip: (string, ExecutionContext.t<'context> => promise<unit>) => unit = "skip"
}
module Only = {
@module("ava") @scope("default")
external test: (string, ExecutionContext.t<'context> => unit) => unit = "only"
@module("ava") @scope("default")
external asyncTest: (string, ExecutionContext.t<'context> => promise<unit>) => unit = "only"
external failing: (string, ExecutionContext.t<'context> => unit) => unit = "only"
@module("ava") @scope(("default", "failing"))
external asyncFailing: (string, ExecutionContext.t<'context> => promise<unit>) => unit = "only"
}
module Skip = {
@module("ava") @scope("default")
external test: (string, ExecutionContext.t<'context> => unit) => unit = "skip"
@module("ava") @scope("default")
external asyncTest: (string, ExecutionContext.t<'context> => promise<unit>) => unit = "skip"
@module("ava") @scope(("default", "beforeEach"))
external beforeEach: (ExecutionContext.t<'context> => unit) => unit = "skip"
@module("ava") @scope(("default", "beforeEach"))
external asyncBeforeEach: (ExecutionContext.t<'context> => promise<unit>) => unit = "skip"
@module("ava") @scope(("default", "before"))
external before: (ExecutionContext.t<'context> => unit) => unit = "skip"
@module("ava") @scope(("default", "before"))
external asyncBefore: (ExecutionContext.t<'context> => promise<unit>) => unit = "skip"
@module("ava") @scope(("default", "afterEach"))
external afterEach: (ExecutionContext.t<'context> => unit) => unit = "skip"
@module("ava") @scope(("default", "afterEach"))
external asyncAfterEach: (ExecutionContext.t<'context> => promise<unit>) => unit = "skip"
@module("ava") @scope(("default", "after"))
external after: (ExecutionContext.t<'context> => unit) => unit = "skip"
@module("ava") @scope(("default", "after"))
external asyncAfter: (ExecutionContext.t<'context> => promise<unit>) => unit = "skip"
}
module Always = {
@module("ava") @scope(("default", "afterEach"))
external afterEach: (ExecutionContext.t<'context> => unit) => unit = "always"
@module("ava") @scope(("default", "afterEach"))
external asyncAfterEach: (ExecutionContext.t<'context> => promise<unit>) => unit = "always"
@module("ava") @scope(("default", "after"))
external after: (ExecutionContext.t<'context> => unit) => unit = "always"
@module("ava") @scope(("default", "after"))
external asyncAfter: (ExecutionContext.t<'context> => promise<unit>) => unit = "always"
module Skip = {
@module("ava") @scope(("default", "afterEach", "always"))
external afterEach: (ExecutionContext.t<'context> => unit) => unit = "skip"
@module("ava") @scope(("default", "afterEach", "always"))
external asyncAfterEach: (ExecutionContext.t<'context> => promise<unit>) => unit = "skip"
@module("ava") @scope(("default", "after", "always"))
external after: (ExecutionContext.t<'context> => unit) => unit = "skip"
@module("ava") @scope(("default", "after", "always"))
external asyncAfter: (ExecutionContext.t<'context> => promise<unit>) => unit = "skip"
}
}
module Assert = {
@send
external is: (ExecutionContext.t<'context>, 'actual, 'actual, ~message: string=?) => unit = "is"
@send
external unsafeIs: (
ExecutionContext.t<'context>,
'actual,
'expected,
~message: string=?,
) => unit = "is"
@send
external deepEqual: (ExecutionContext.t<'context>, 'actual, 'actual, ~message: string=?) => unit =
"deepEqual"
@send
external unsafeDeepEqual: (
ExecutionContext.t<'context>,
'actual,
'expected,
~message: string=?,
) => unit = "deepEqual"
@send
external regex: (ExecutionContext.t<'context>, string, Js.Re.t, ~message: string=?) => unit =
"regex"
@send
external throws: (
ExecutionContext.t<'context>,
unit => 'a,
~expectations: ThrowsExpectation.t=?,
~message: string=?,
) => unit = "throws"
@send
external throwsAsync: (
ExecutionContext.t<'context>,
promise<'a>,
~expectations: ThrowsExpectation.t=?,
~message: string=?,
) => promise<unit> = "throwsAsync"
@send
external not: (ExecutionContext.t<'context>, 'actual, 'expected, ~message: string=?) => unit =
"not"
@send
external notDeepEqual: (
ExecutionContext.t<'context>,
'actual,
'expected,
~message: string=?,
) => unit = "notDeepEqual"
@send
external notRegex: (ExecutionContext.t<'context>, string, Js.Re.t, ~message: string=?) => unit =
"notRegex"
@send
external snapshot: (ExecutionContext.t<'context>, 'expected, ~message: string=?) => unit =
"snapshot"
@send
external notThrows: (ExecutionContext.t<'context>, unit => 'a, ~message: string=?) => unit =
"notThrows"
@send
external notThrowsAsync: (
ExecutionContext.t<'context>,
promise<'a>,
~message: string=?,
) => promise<unit> = "notThrowsAsync"
@send external fail: (ExecutionContext.t<'context>, string) => 'any = "fail"
@send external pass: (ExecutionContext.t<'context>, ~message: string=?) => unit = "pass"
@send
external like: (ExecutionContext.t<'context>, 'actual, 'selector, ~message: string=?) => unit =
"like"
@send
external falsy: (ExecutionContext.t<'context>, 'actual, ~message: string=?) => unit = "falsy"
@send
external truthy: (ExecutionContext.t<'context>, 'actual, ~message: string=?) => unit = "truthy"
@send
external isFalse: (ExecutionContext.t<'context>, 'actual, ~message: string=?) => unit = "false"
@send
external isTrue: (ExecutionContext.t<'context>, 'actual, ~message: string=?) => unit = "true"
module Skip = {
@send @scope("is")
external is: (ExecutionContext.t<'context>, 'value, 'value, ~message: string=?) => unit = "skip"
@send @scope("is")
external unsafeIs: (
ExecutionContext.t<'context>,
'actual,
'expected,
~message: string=?,
) => unit = "skip"
@send @scope("deepEqual")
external deepEqual: (ExecutionContext.t<'context>, 'value, 'value, ~message: string=?) => unit =
"skip"
@send @scope("deepEqual")
external unsafeDeepEqual: (
ExecutionContext.t<'context>,
'actual,
'expected,
~message: string=?,
) => unit = "skip"
@send @scope("regex")
external regex: (ExecutionContext.t<'context>, string, Js.Re.t, ~message: string=?) => unit =
"skip"
@send @scope("throws")
external throws: (
ExecutionContext.t<'context>,
unit => 'a,
~expectations: ThrowsExpectation.t=?,
~message: string=?,
) => unit = "skip"
@send @scope("throwsAsync")
external throwsAsync: (
ExecutionContext.t<'context>,
promise<'a>,
~expectations: ThrowsExpectation.t=?,
~message: string=?,
) => promise<unit> = "skip"
@send @scope("not")
external not: (ExecutionContext.t<'context>, 'actual, 'expected, ~message: string=?) => unit =
"skip"
@send @scope("notDeepEqual")
external notDeepEqual: (
ExecutionContext.t<'context>,
'actual,
'expected,
~message: string=?,
) => unit = "skip"
@send @scope("notRegex")
external notRegex: (ExecutionContext.t<'context>, string, Js.Re.t, ~message: string=?) => unit =
"skip"
@send @scope("snapshot")
external snapshot: (ExecutionContext.t<'context>, 'expected, ~message: string=?) => unit =
"skip"
@send @scope("notRegex")
external notThrows: (ExecutionContext.t<'context>, unit => 'a, ~message: string=?) => unit =
"skip"
@send @scope("notThrowsAsync")
external notThrowsAsync: (
ExecutionContext.t<'context>,
promise<'a>,
~message: string=?,
) => promise<unit> = "skip"
@send @scope("fail") external fail: (ExecutionContext.t<'context>, string) => 'any = "skip"
@send @scope("pass")
external pass: (ExecutionContext.t<'context>, ~message: string=?) => unit = "skip"
@send @scope("like")
external like: (ExecutionContext.t<'context>, 'actual, 'selector, ~message: string=?) => unit =
"skip"
@send @scope("falsy")
external falsy: (ExecutionContext.t<'context>, 'actual, ~message: string=?) => unit = "skip"
@send @scope("truthy")
external truthy: (ExecutionContext.t<'context>, 'actual, ~message: string=?) => unit = "skip"
@send @scope("false")
external isFalse: (ExecutionContext.t<'context>, 'actual, ~message: string=?) => unit = "skip"
@send @scope("true")
external isTrue: (ExecutionContext.t<'context>, 'actual, ~message: string=?) => unit = "skip"
}
}