rescript-test is a lightweight and performant test framework designed specifically for ReScript projects. Currently at version 8.0.0, it provides a native ReScript API for writing unit and integration tests, leveraging ReScript's type system for robust assertions. It integrates directly into the ReScript build pipeline, running compiled `.bs.js` files. The framework offers core testing primitives like `test`, `testAsync`, and flexible `assertion` functions, alongside utilities for setup/teardown and optional DOM simulation via JSDOM. It aims to provide a straightforward, type-safe testing experience tailored for the ReScript ecosystem, differentiating itself from general JavaScript test runners by its deep integration with ReScript's language features. It appears to be actively maintained, with updates typically correlating with ReScript compiler releases.
npm install rescript-testVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to install `rescript-test`, configure `bsconfig.json`, write a basic ReScript test file with custom assertions, and execute it using the `retest` CLI.
Ensure your project's `rescript` dependency matches or exceeds `^12.0.1`. Update ReScript compiler version if necessary via `npm install rescript@latest`.
Upgrade your Node.js runtime environment to version 20.0.0 or newer. Use a version manager like `nvm` to easily switch Node.js versions.
Write your tests in ReScript (`.res` files) and compile them to JavaScript. Then, use the `retest` CLI to run the compiled `.bs.js` test files.
Install `jsdom` as a dev dependency (`yarn add --dev jsdom`) and execute tests with `npx retest --with-dom 'test/**/*.bs.js'`.
Ensure `rescript-test` is listed in your `bs-dev-dependencies` array within `bsconfig.json` and that `yarn add --dev rescript-test` has been run successfully.
Install `rescript-test` as a dev dependency (`yarn add --dev rescript-test`). If installed, try running with `npx retest ...` to execute the local package binary.
Review your ReScript test code for type errors highlighted by the ReScript compiler. Ensure arguments passed to assertions like `intEqual` or `stringEqual` match their defined types. Recompile your ReScript code (`npm run res:build` or `yarn res:build`) before running tests.
Examine the test case where the failure occurred. Debug the values being compared against your assertion logic to understand why the condition `(a, b) => a === b` or your custom comparator returned `false`.