rescript-jest
rescript-jest copied to clipboard
Tests would timeout under ReScript v11.0.0-rc.4 with `uncurried: false`
Just change Rescript to v11.0.0-rc.4 and add uncurried: false to bsconfig.json, npm test will fail with timeout.
It seems like Rescript v11 adds a param to the callback of test function which causes the timeout.
with uncurried: false in bsconfig.json
function test$1(name, callback) {
test(name, (function (param) {
affirm(Curry._1(callback, undefined));
}));
}
without uncurried: fase in bsconfig.json (ie: default uncurried mode)
function test$1(name, callback) {
test(name, (function () {
affirm(callback(undefined));
}));
}
Here is the repo to demonstrate: https://github.com/dsiu/rescript-jest/tree/rescript-v11-curried-mode
Not sure if this can/should be solved here.
Any suggestions @zth, @cristianoc?
When I change this line https://github.com/glennsl/rescript-jest/blob/817581ea92b98d510bb2cc6d2529d8b0c76d6c56/src/jest.res#L138
to
@val external _test: (string, (. unit) => Js.undefined<unit>) => unit = "test"
and adapt the callsites to using (. ()) as well, it works!
I applied the changes @fhammerschmidt suggested to _test and all other related @uncurry functions like testPromise describe etc in my fork https://github.com/dsiu/rescript-jest/commit/87cbdb14e104b69b5a926afc2bbc9202debbc5a8, and all tests passed in uncurried: false with Rescript-v11.0.0-rc.6! 🎉
Does it also work seamlessly with v10?
I just hit this, and yes rescript-jest with those changes does still work if I downgrade my project to v10 (and then re-apply the changes).
That suggests @uncurry externals don't behave properly in v11 with uncurried: false - perhaps a lurking bug. Certainly I'm not sure whether it's safe to remove them all in rescript-jest.
It's a breaking change in 10 in that it requires functions to be applied with .. But let's give it a go anyway. All tests pass in 11. Users on 10 can keep using 0.10.
Should be fixed in 0.11. Let me know if there are any issues.