Skip to content

Trouble using with inline_test_ppx #7

@evelant

Description

@evelant

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions