glennsl/rescript-jest

Expect method not_ is not bound?

kristianmandrup opened this issue · 2 comments

Telling me: not_ and toThrow are not bound, while toEqual is bound.
What am I doing wrong? Please update the tests included to follow latest syntax and provide better docs to get started, using bs-platform 4.0.x, migrating from Jest in JavaScript land. Thanks :)

Error: Unbound value not__
Hint: Did you mean not_?

But why is it complaining about not__ when I clearly wrote not_ in the code? Makes no sense

I'm trying to make a simple binding of html method in lit-html following this [binding tutorial](https://itnext.io/reasonml-create-bindings-for-npm-package-b8a3c6d0703e

src/LitHtml.re

[@bs.module "LitHtml"] [@bs.val]
external html: string => Js.nullable(string) = "html";
let html = htmlStr => html(htmlStr) |> Js.Nullable.toOption;

Tests

open Jest;

let write = () => LitHtml.html("<div></div>")

open Expect;

describe("LitHtml", () =>
  test("#html", () =>
    expect(() => write()) |> not_ |> toThrow
  )
);

describe("Calc", () =>
  test("#add", () =>
    expect(1 + 1) |> toEqual(1)
  )
);

I tried all kinds of combinations with Expect but so far to no avail.

Posted the question on Stackoverflow as well

Hey. Unfortunately I don't know why it would do that. It converts not_ correctly if I put your code into the Reason playground.

It might be that this is brand new, and that the Reason playground hasn't been updated yet. And it could be that this is a kind of mangling is done to support reserved OCaml keywords in Reason. You might try using not instead of not_.

Other than that, there isn't anything I can do about it here, so I'll close the issue. I recommend you either just wait for assistance in the other forums, or create an issue on https://github.com/facebok/reason since it's most likely an issue (or "feature") with Reason itself.

Turns out it was due to multiple conflicting versions of refmt due to VSCode extensions and reason-cli global install.

Solution

$ npm uninstall -g reason-cli

Uninstall OCaml and Reason IDE VSCode extension. Reload VS Code.