Sorry to go off topic, but what is it about async/await compatibility? Is it the ReScript async/await, or the JS async/await?
Itās ReScriptā async/await and Js.Promise2
You might find the discussions interesting:
Iām giving this a try. When the .test.res file is changed, the underlying .test.bs.js file is updated as expected. I can look at the .bs.js file and see something like expect(4).toEqual(5)
But the vitest output in the terminal still shows everything passing. I have to go into the .test.bs.js file and save it, causing a reformat, for vitest to notice the test has changed and update the results. Somehow the vitest watcher isnāt noticing when the auto-generated .bs.js file is changed. Have you seen this?
ā-
I set the vitest config include property to look for the generated test.bs.js files so I donāt know why it doesnāt notice when these files change. I have to change them manually by doing a file save on them. How is your vitest configured? Is some rescript plug-in or something needed?
When I attempt to use the vite-plugin-rescript installation instructions Iām receiving an error that the Js.Promise2
library is not found. This is using:
"devDependencies": {
"@jihchi/vite-plugin-rescript": "^5.0.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@vitejs/plugin-react": "^3.0.1",
"jsdom": "^21.0.0",
"rescript-vitest": "^1.0.1",
"vite": "^4.0.4",
"vitest": "^0.26.3"
},
"dependencies": {
"@rescript/react": "0.11",
"@ryyppy/rescript-promise": "^2.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rescript": "^10.0.1",
"rescript-webapi": "^0.7.0"
}
}
Is this a known incompatibility?
You need to use rescript@10.1.x
The watcher problem I was having fixed itself when I upgraded vitest to ^0.27.1. But now I have a different issue. Are there any special steps you need to take to install rescript-vitest to get it working? Iāve done thisā¦
- Add
rescript-vitest
todevDependencies
inpackage.json
- Add
rescript-vitest
tobs-dependencies
inbsconfig.json
- Configure
vite.config.js
to something like thisā¦
export default defineConfig({
plugins: [react()],
test: {
include: [...configDefaults.include, "**/*.{test,spec}.bs.js"],
},
});
My tests wonāt run. I get this errorā¦
Error: No test suite found in
file /Users/.../Source/vite-experiments/vite2/src/MathTest.test.bs.js
Here is the generated test fileā¦
// Generated by ReScript, PLEASE EDIT WITH CARE
import * as Vitest from "rescript-vitest/src/Vitest.bs.js";
import * as Vitest$1 from "vitest";
Vitest.describe("Math test suite", undefined, function (param) {
Vitest.test("addition", 2500, function (_t) {
Vitest$1.expect(8).toEqual(8);
});
});
export {};
/* Not a pure module */
Note that if I instead copy the Vitest.res
file into my project src
folder, as if I wrote it myself, the tests run just fine. I searched the internet for āvitest No test suite foundā it looks like there are some similar bugs in the vitest repository.
Iāll add a section to the README about the including files setting.
The problem you reported is probably related to the bundler.
Could you try to resolve it with refering to Dep Optimization Options | Vite?
Sorry I barely understand the docs on Dep Optimization Options and how this could relate to the problem Iām seeing with No Test Suite found. I donāt know what to try.
Iām porting my tests over to your bindings. I use data driven tests a lot, like test.each
, and it doesnāt look like this is implemented in your bindings. Iāve started trying to write these bindings; just trying to get a bare minimum working. It doesnāt follow your current approach of functors. Iām not very familiar with vitest. Iām just trying to get something to compile. You could probably do it properly a LOT faster than me. I think we need testObject - for an array of objects - and test2, test3, test4, etc. for test case arrays of length 2, 3, 4, etc. And these need async and non-async version. And the timeout options. Iāve gotten these below to work.
module Each = {
type test
@module("vitest") @val
external _test: test = "test"
@send
external _testObj: (
~test: test,
~cases: array<'c>,
. ~name: string,
~f: @uncurry ('c => unit),
~param: Js.undefined<int>,
) => unit = "each"
@send
external _testArray2: (
~test: test,
~cases: array<('a, 'b)>,
. ~name: string,
~f: @uncurry ('a, 'b) => unit,
~param: Js.undefined<int>,
) => unit = "each"
@inline
let testObject = (cases, name, f) =>
_testObj(~test=_test, ~cases)(. ~name, ~f, ~param=Js.Undefined.empty)
@inline
let test2 = (cases, name, f) =>
_testArray2(~test=_test, ~cases)(. ~name, ~f, ~param=Js.Undefined.empty)
}
I finished the bindings for test.each and describe.each. Tried creating a pull request - never done this before. Check it out.
Sorry, I meant vitest config something like:
// in your vitest.config.ts or vite.config.ts
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
deps: {
inline: true, // this
fallbackCjs: true, // or this
},
},
});