Skip to content

Commit 62adb47

Browse files
committed
Add t->skip and t->skipIf bindings
1 parent 77861a2 commit 62adb47

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/Vitest.res

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,12 @@ external hasAssertion: testCtxExpect => unit = "hasAssertion"
13021302
@inline
13031303
let hasAssertion = testCtx => testCtx->inner->hasAssertion
13041304

1305+
@send external skip: (testCtx, ~note: string=?) => unit = "skip"
1306+
1307+
@send external skipIf: (testCtx, bool, ~note: string=?) => unit = "skip"
1308+
@inline
1309+
let skipIf = (testCtx, ~note=?, condition) => testCtx->skipIf(condition, ~note?)
1310+
13051311
@scope("import.meta") @val
13061312
external inSource: bool = "vitest"
13071313

tests/basic.test.res

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,21 @@ let throwExn = () => {
3535
test("Exn", t => {
3636
t->expect(() => throwExn())->Expect.toThrowError
3737
})
38+
39+
test(~skip=true, "Skip 1", t => {
40+
t->expect(true)->Expect.toBeTruthy
41+
})
42+
43+
test("Skip 2", t => {
44+
t->skip(~note="Skipping this test")
45+
t->expect(true)->Expect.toBeFalsy
46+
})
47+
48+
test("Skip 3", t => {
49+
t->skipIf(true)
50+
t->expect(true)->Expect.toBeFalsy
51+
})
52+
53+
test(~fails=true, "Fails", t => {
54+
t->expect(true)->Expect.toBeFalsy
55+
})

0 commit comments

Comments
 (0)