Hi there !
vitest-bdd
A testing solution based on vitest that plays nice with ReScript.
I was finally annoyed at not having source maps and a simple testing solution for ReScript.
This plugin was initially created to support Gherkins tests with step definitions in ReScript or TypeScript but I thought that adding support for unit tests was a nice addition.
And then… I added source maps ! to the test files by retro-pedaling the compiled sources.
Usage
pnpm add -D vitest-bdd
import { vitestBdd } from "vitest-bdd";
import { defineConfig } from "vitest/config";
export default defineConfig({
plugins: [ vitestBdd() ],
test: {
pool: "threads",
include: ["**/*.feature", "**/*.md", "**/*.spec.ts", "**/*_test.res"],
},
});
Make sure to include the *.res file, not the compiled source.
If you want to keep compiling out of source, you can add your own resolver function for the compiled source in the options:
export type VitestBddOptions = { // defaults
debug?: boolean; // false
markdownExtensions?: string[]; // [".md", ".mdx", ".markdown"]
gherkinExtensions?: string[]; // [".feature"]
rescriptExtensions?: string[]; // [".res"]
stepsResolver?: (path: string) => string | null;
resCompiledResolver?: (path: string) => string | null;
};
More information and a working test app on github (please star the project if you like it
).
Feedback and experiences welcome !
PS: You can use “vitest” without “vite” (I use it in my react-native expo project)
vitest-bdd