Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cometkim/rescript-vitest
ReScript bindings to Vitest
https://github.com/cometkim/rescript-vitest
rescript rescript-bindings vite vitest
Last synced: about 2 months ago
JSON representation
ReScript bindings to Vitest
- Host: GitHub
- URL: https://github.com/cometkim/rescript-vitest
- Owner: cometkim
- License: mit
- Created: 2022-01-16T07:43:58.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-21T07:02:05.000Z (5 months ago)
- Last Synced: 2024-05-01T15:35:14.118Z (5 months ago)
- Topics: rescript, rescript-bindings, vite, vitest
- Language: ReScript
- Homepage:
- Size: 2.37 MB
- Stars: 41
- Watchers: 3
- Forks: 7
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rescript-vitest
[![npm](https://img.shields.io/npm/v/rescript-vitest)](https://www.npmjs.com/package/rescript-vitest)
[![npm downloads](https://img.shields.io/npm/dm/rescript-vitest)](https://www.npmjs.com/package/rescript-vitest)
[![license](https://img.shields.io/github/license/cometkim/rescript-vitest)](#LICENSE)[ReScript](https://rescript-lang.org) bindings to [Vitest](https://vitest.dev)
## Prerequisite
ReScript v10.1+ is required since v1.0.0. To use `Js.Promise2` and `async`/`await` for tests.
ReScript v11 can be used with `"uncurried": false`
## Config
Configure with plain `vite.config.js`.
You can use [vite-plugin-rescript](https://github.com/jihchi/vite-plugin-rescript) to build ReScript automatically before the test.
## Usage
You can find examples on [tests](./tests)
### Basic
```res
open Vitestdescribe("Hello, Vitest", () => {
test("This is a test case", t => {
// t is `expect` object for suite-wide assertions
t->assertions(3)// Test using the `Expect` module
expect(1 + 2)->Expect.toBe(3)// There are some nested modules for specific type
expect([1, 2, 3])
->Expect.Array.toContain(2)expect("Hello, ReScript-Vitest!")
->Expect.String.toContain("ReScript")// You can specify timeout for a test suite
}, ~timeout=2000)
})
```### In-source testing (experimental)
Vitest support [in-source testing](https://vitest.dev/guide/in-source)
```res
// This if block can be removed from production code.
// You need to define `import.meta.vitest` to `undefined`
if Vitest.inSource {
open Vitest
open Vitest.InSourcetest("In-source testing", _ => {
expect(1 + 2)->Expect.toBe(3)
})
}
```## LICENCE
MIT