Rescript and Deno, Js.log or test output not showing up

Hi!

I’m trying Deno and wanted to write some tests, so I wrote some bindings. When I write my test though, the function seems to be curried with the two parameters it needs, but it looks like it isn’t called and my output doesn’t show :frowning:

I read the docs to see what I was missing, besides the uncurried syntax with . which I’d like to avoid because it is very ugly, it mentions @uncurry which I tried but it did nothing.

Here is the code sample (and a playground link)

module Test = {
  @scope("Deno") @val
  external test: (string, @uncurry unit => unit) => unit = "test"

  @scope("Deno") @val
  external testAsync: (string, @uncurry unit => Js.Promise.t<unit>) => unit =
    "test"

  @module("https://deno.land/std@0.97.0/testing/asserts.ts")
  external assertTrue: (bool, string) => unit = "assert"

  type testFunctions = {
    test: (string, unit => unit) => unit,
    testAsync: (string, unit => Js.Promise.t<unit>) => unit,
  }

  let suite = (scope: string, testFn: testFunctions => unit): unit => {
    let testFns: testFunctions = {
      test: (subject, fn) => test(`${scope}: ${subject}`, fn),
      testAsync: (subject, fn) => testAsync(`${scope}: ${subject}`, fn),
    }
    testFn(testFns)->ignore
  }
}

module Something = {
  let tests = Test.suite("Something", ({test}) => {
    test("a test", () => {
      Js.log("Hello?")
      Test.assertTrue(false, "assert")
    })
  })
}

Does anyone know what I’m tripping against here? I’ve been trying rescript for a while and it is the first time this has happened to me despite never using the uncurried function syntax.

Thanks!

I realize now that my @uncurry annotations are not really useful there, and I can’t apply them to the whole external definition.

I’m not sure if this is happening because of my strange usage of a record with functions on it. I’ll keep investigating.

Welp sorry about the noise, it seems like Deno tests need to be run with deno test and if you run the file normally then it doesn’t run the tests, the rescript code and currying application is working fine :confused:

Feel free to delete this thread, I tried but it is not letting me do it.

No need to delete, it’s probably useful for someone else stumbling on this. Also great to see that you are trying ReScript with Deno!

2 Likes