inline-test-ppx icon indicating copy to clipboard operation
inline-test-ppx copied to clipboard

Async import generated by inline-test-ppx doesn't work with rescript-test

Open evelant opened this issue 3 years ago • 6 comments

The generated test import files use an async import like so:

import("../../src/myfile.mjs").catch(e => {
  if (e.code !== "ERR_MODULE_NOT_FOUND") reject(e)
});

but that breaks rescript-test, it will always find 0 tests because the import hasn't resolved yet when it tries to run them

changing it to a synchronous import makes it work correctly

import "../../src/myfile.mjs"

evelant avatar Feb 10 '22 16:02 evelant

Notice though that when it's synchronous it'll crash when you end up moving a file containing tests. Do you have any ideas how to work around it?

wokalski avatar Feb 10 '22 16:02 wokalski

I'm just getting started with rescript, I'm not sure how to best work around this. Moving a file containing tests doesn't happen very often does it? A note in the docs along the lines of "if you move a file containing tests you need to clean/rebuild" might be good enough?

evelant avatar Feb 10 '22 18:02 evelant

I don't think it's a trade off we're willing to accept.

I suggest to fix it in rescript test. Jest and zora work well with this ppx.

wokalski avatar Feb 10 '22 20:02 wokalski

I think rescript-test does some name mangling when building out of source, we'll investigate how to make it compatible with inline-test-ppx.

tsnobip avatar Feb 21 '22 10:02 tsnobip

@tsnobip Do you think it's that? Notice the change @evelant had to make to make the ppx work 🤔

wokalski avatar Feb 22 '22 08:02 wokalski

yeah @wokalski I guess this is something else.

tsnobip avatar Feb 22 '22 10:02 tsnobip