rescript-jest icon indicating copy to clipboard operation
rescript-jest copied to clipboard

Tests would timeout under ReScript v11.0.0-rc.4 with `uncurried: false`

Open dsiu opened this issue 2 years ago • 4 comments

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

dsiu avatar Oct 14 '23 07:10 dsiu

Not sure if this can/should be solved here.

Any suggestions @zth, @cristianoc?

glennsl avatar Oct 19 '23 13:10 glennsl

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!

fhammerschmidt avatar Nov 30 '23 13:11 fhammerschmidt

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! 🎉

dsiu avatar Dec 01 '23 07:12 dsiu

Does it also work seamlessly with v10?

glennsl avatar Dec 01 '23 12:12 glennsl

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.

TheSpyder avatar Apr 18 '24 00:04 TheSpyder

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.

glennsl avatar Apr 21 '24 19:04 glennsl

Should be fixed in 0.11. Let me know if there are any issues.

glennsl avatar Apr 21 '24 19:04 glennsl