Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dzakh/rescript-ava
🪲 ReScript bindings for Ava
https://github.com/dzakh/rescript-ava
ava nodejs rescript rescript-bindings tdd test-framework test-runner testing
Last synced: 20 days ago
JSON representation
🪲 ReScript bindings for Ava
- Host: GitHub
- URL: https://github.com/dzakh/rescript-ava
- Owner: DZakh
- License: mit
- Created: 2022-02-24T17:49:26.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-22T16:28:30.000Z (8 months ago)
- Last Synced: 2024-12-13T21:44:16.903Z (20 days ago)
- Topics: ava, nodejs, rescript, rescript-bindings, tdd, test-framework, test-runner, testing
- Language: ReScript
- Homepage:
- Size: 106 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rescript-ava
Runtime free [ReScript](https://github.com/rescript-lang) bindings for [Ava](https://github.com/avajs/ava)
## Usage
### Installation
```sh
npm install -D @dzakh/rescript-ava [email protected]
```Then add `@dzakh/rescript-ava` to `bs-dev-dependencies` in your `rescript.json`:
```diff
{
...
+ "bs-dev-dependencies": ["@dzakh/rescript-ava"]
}
```Then add `__tests__` to `sources` in your `rescript.json`:
```diff
"sources": [
{
"dir": "src"
},
+ {
+ "dir": "__tests__",
+ "type": "dev"
+ }
]
```Then add `test` script and minimalistic configuration in your `package.json`:
```diff
{
"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](https://github.com/avajs/ava), see [the Ava documentation](https://github.com/avajs/ava#documentation).
```res
// __tests__/Main_test.res
open Avatest("foo", t => {
t->Assert.pass
})asyncTest("bar", t => {
Promise.resolve("bar")->Promise.thenResolve(bar => {
t->Assert.is(bar, "bar")
})
})```
### Running your tests
```sh
npm test
```Or with npx:
```sh
npx ava
```Run with the --watch flag to enable AVA's [watch mode](https://github.com/avajs/ava/blob/main/docs/recipes/watch-mode.md):
```sh
npx ava --watch
```## Documentation
For the moment, please refer to [Ava.res](./src/Ava.res).
## Examples
Open source projects using **rescript-ava**:
- [rescript-schema](https://github.com/DZakh/rescript-schema) - The fastest composable parser/serializer for ReScript (and TypeScript)
- [rescript-envsafe](https://github.com/DZakh/rescript-envsafe) - Makes sure you don't accidentally deploy apps with missing or invalid environment variables
- [rescript-json-schema](https://github.com/DZakh/rescript-json-schema) - Typesafe JSON schema for ReScript