|
1 | 1 | type given = {step: 'a. (string, 'a) => unit} |
2 | 2 | type assertions<'a> = {toBe: 'a => unit, toEqual: 'a => unit} |
3 | 3 |
|
| 4 | +// ========= Gherkin ========== |
| 5 | + |
4 | 6 | @module("vitest-bdd") |
5 | 7 | external given: (string, (given, 'args) => unit) => unit = "Given" |
6 | 8 |
|
| 9 | +// ========= Vitest ========== |
| 10 | + |
| 11 | +type rec testContext = { |
| 12 | + onTestFailed: 'a. (testContext => 'a) => unit, |
| 13 | + onTestFinished: 'a. (testContext => 'a) => unit, |
| 14 | +} |
| 15 | + |
7 | 16 | @module("vitest") |
8 | 17 | external expect: 'a => assertions<'a> = "expect" |
| 18 | + |
| 19 | +@module("vitest") |
| 20 | +external concurrent: (string, unit => unit) => unit = "describe.concurrent" |
| 21 | + |
| 22 | +@module("vitest") |
| 23 | +external beforeAll: (string, 'a) => unit = "beforeAll" |
| 24 | + |
| 25 | +@module("vitest") |
| 26 | +external beforeEach: (string, 'a) => unit = "beforeEach" |
| 27 | + |
| 28 | +@module("vitest") |
| 29 | +external afterAll: (string, 'a) => unit = "afterAll" |
| 30 | + |
| 31 | +@module("vitest") |
| 32 | +external afterEach: (string, 'a) => unit = "afterEach" |
| 33 | + |
| 34 | +@module("vitest") |
| 35 | +external onTestFinished: (unit => unit) => unit = "onTestFinished" |
| 36 | + |
| 37 | +@module("vitest") |
| 38 | +external onTestFailed: (unit => unit) => unit = "onTestFinished" |
| 39 | +// ========= Modes ========== |
| 40 | + |
| 41 | +@module("vitest") |
| 42 | +external describe: (string, unit => unit) => unit = "describe" |
| 43 | + |
| 44 | +@module("vitest") |
| 45 | +external bench: (string, unit => unit) => unit = "bench" |
| 46 | + |
| 47 | +@module("vitest") |
| 48 | +external test: (string, 'a) => unit = "test" |
| 49 | + |
| 50 | +@module("vitest") |
| 51 | +external it: (string, 'a) => unit = "it" |
| 52 | + |
| 53 | +module Skip = { |
| 54 | + @module("vitest") @scope("describe") |
| 55 | + external describe: (string, unit => unit) => unit = "skip" |
| 56 | + |
| 57 | + @module("vitest") @scope("bench") |
| 58 | + external bench: (string, unit => unit) => unit = "skip" |
| 59 | + |
| 60 | + @module("vitest") @scope("test") |
| 61 | + external test: (string, 'a) => unit = "skip" |
| 62 | + |
| 63 | + @module("vitest") @scope("it") |
| 64 | + external it: (string, 'a) => unit = "skip" |
| 65 | +} |
| 66 | + |
| 67 | +module Only = { |
| 68 | + @module("vitest") @scope("describe") |
| 69 | + external describe: (string, unit => unit) => unit = "only" |
| 70 | + |
| 71 | + @module("vitest") @scope("bench") |
| 72 | + external bench: (string, unit => unit) => unit = "only" |
| 73 | + |
| 74 | + @module("vitest") @scope("test") |
| 75 | + external test: (string, 'a) => unit = "only" |
| 76 | + |
| 77 | + @module("vitest") @scope("it") |
| 78 | + external it: (string, 'a) => unit = "only" |
| 79 | +} |
| 80 | + |
| 81 | +module Todo = { |
| 82 | + @module("vitest") @scope("describe") |
| 83 | + external describe: string => unit = "todo" |
| 84 | + |
| 85 | + @module("vitest") @scope("bench") |
| 86 | + external bench: string => unit = "todo" |
| 87 | + |
| 88 | + @module("vitest") @scope("test") |
| 89 | + external test: string => unit = "todo" |
| 90 | + |
| 91 | + @module("vitest") @scope("it") |
| 92 | + external it: string => unit = "todo" |
| 93 | +} |
0 commit comments