3.1.0 • Published 10 months ago
@dzakh/rescript-ava v3.1.0
rescript-ava
Runtime free ReScript bindings for Ava
Usage
Installation
npm install -D @dzakh/rescript-ava avaThen add @dzakh/rescript-ava to bs-dev-dependencies in your rescript.json:
{
...
+ "bs-dev-dependencies": ["@dzakh/rescript-ava"]
}Then add __tests__ to sources in your rescript.json:
"sources": [
{
"dir": "src"
},
+ {
+ "dir": "__tests__",
+ "type": "dev"
+ }
]Then add test script and minimalistic configuration in your package.json:
{
"name": "awesome-package",
"scripts": {
+ "test": "ava"
},
"devDependencies": {
"@dzakh/rescript-ava": "latest"
},
+ "ava": {
+ "files": [
+ "__tests__/**/*_test.mjs",
+ "__tests__/**/*_test.bs.js"
+ ]
+ }
}Create your test file
Create a test file in the tests directory and use the suffix *_test.res. When compiled they will be put in a tests directory with a *_test.bs.js suffix, ready to be picked up when you run ava. If you're not already familiar with Ava, see the Ava documentation.
// __tests__/Main_test.res
open Ava
test("foo", t => {
t->Assert.pass
})
asyncTest("bar", t => {
Promise.resolve("bar")->Promise.thenResolve(bar => {
t->Assert.is(bar, "bar")
})
})Running your tests
npm testOr with npx:
npx avaRun with the --watch flag to enable AVA's watch mode:
npx ava --watchDocumentation
For the moment, please refer to Ava.res.
Examples
Open source projects using rescript-ava:
- rescript-schema - The fastest parser in the entire JavaScript ecosystem with a focus on small bundle size and top-notch DX
- rescript-rest - RPC-like client, contract, and server implementation for a pure REST API
- rescript-envsafe - Makes sure you don't accidentally deploy apps with missing or invalid environment variables
- rescript-json-schema - Typesafe JSON schema for ReScript