You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
openVitestdescribe("Hello, Vitest", () => {
test("This is a test case", t=> {
// t is `expect` object for suite-wide assertionst->assertions(3)
// Test using the `Expect` modulet->expect(1+2)->Expect.toBe(3)
// There are some nested modules for specific typet->expect([1, 2, 3])
->Expect.Array.toContain(2)
t->expect("Hello, ReScript-Vitest!")
->Expect.String.toContain("ReScript")
// You can specify timeout for a test suite
}, ~timeout=2000)
})
// This if block can be removed from production code.// You need to define `import.meta.vitest` to `undefined`ifVitest.inSource {
openVitest.InSourcetest("In-source testing", t=> {
t->expect(1+2)->Expect.toBe(3)
})
}
Migration from 1.x
You need to bind test context t explicitly.
open Vitest
describe("Hello, Vitest", () => {
- test("This is a test case", _ => {+ test("This is a test case", t => {- assertions(3)+ t->assertions(3)- expect(1 + 2)->Expect.toBe(3)+ t->expect(1 + 2)->Expect.toBe(3)
})
})
You can use simple flags for skip, concurrent, and only.
Skip.test("This will be skipped", t=> {
// ...
})
// Use simple flags instead.test(~skip=true, "This will be skipped", t=> {
// ...
})
Module bindings will be deprecated and removed in next major (v3)