-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
try-fn.d.cts
58 lines (47 loc) · 1.48 KB
/
try-fn.d.cts
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
import type {Implementation} from './test-fn.cjs';
export type CommitDiscardOptions = {
/**
* Whether the logs should be included in those of the parent test.
*/
retainLogs?: boolean;
};
export type AssertionError = Record<string, unknown> & Error;
export type TryResult = {
/**
* Title of the attempt, helping you tell attempts aparts.
*/
title: string;
/**
* Indicates whether all assertions passed, or at least one failed.
*/
passed: boolean;
/**
* Errors raised for each failed assertion.
*/
errors: AssertionError[];
/**
* Logs created during the attempt using `t.log()`. Contains formatted values.
*/
logs: string[];
/**
* Commit the attempt. Counts as one assertion for the plan count. If the
* attempt failed, calling this will also cause your test to fail.
*/
commit(options?: CommitDiscardOptions): void;
/**
* Discard the attempt.
*/
discard(options?: CommitDiscardOptions): void;
};
export type TryFn<Context = unknown> = {
/**
* Attempt to run some assertions. The result must be explicitly committed or discarded or else
* the test will fail. The title may help distinguish attempts from one another.
*/
<Args extends unknown[]>(title: string, fn: Implementation<Args, Context>, ...args: Args): Promise<TryResult>;
/**
* Attempt to run some assertions. The result must be explicitly committed or discarded or else
* the test will fail.
*/
<Args extends unknown[]>(fn: Implementation<Args, Context>, ...args: Args): Promise<TryResult>;
};