Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble using with inline_test_ppx #7

Open
evelant opened this issue Feb 12, 2022 · 1 comment
Open

Trouble using with inline_test_ppx #7

evelant opened this issue Feb 12, 2022 · 1 comment

Comments

@evelant
Copy link

evelant commented Feb 12, 2022

I'm trying to use rescript-test with inline_test_ppx and am running into some difficulty. inline_test_ppx outputs files as lib/bs/__inline_test.*.mjs. This seems to cause two problems, first it trips up the path logic in rescript-test resulting in

npx retest lib/bs/__inline_test.*.mjs
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/myuser/dev/myproject/rescript/node_modules/rescript-test/lib/bs/src/Test.mjs' imported from /Users/myuser/dev/myproject/rescript/node_modules/rescript-test/bin/retest.mjs

This can be worked around by changing the path provided to retest

npx retest ../rescript/lib/bs/__inline_test.*.mjs
//it runs 

Unfortunately there is another issue, rescript-test always reports 0 tests even though it's picking up the correct files. This appears to be due to inline_test_ppx using an async require of the target file. For example, the lib/bs/__inline_test.mymodule.mjs will contain something like

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

This causes rescript-test to always find 0 tests to run. If I manually change it to a synchronous import like so

import "../../src/mymodule.mjs"

then the tests are found and everything works correctly. I'm not quite sure why rescript-test isn't working with that async import style.

@bloodyowl
Copy link
Owner

Hi!

Can you create a small repro for the path issue?

For the second point, ReScript Test waits to modules to be imported, computes the tests to execute then runs them in sequence. This is by design to avoid having missed tests. The way the code is generated here seems to indicate there's no way to indicate to the runner that all the tests are ready, so even by adapting the binary, I'm not sure there's much we can do here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants