1

Trying to test a binding of lit-html method html

open Jest;

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

open Expect;

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

I am told this cryptic error:

Error: Unbound value not__
Hint: Did you mean not_?
Jest.Expect.plainPartial('a) => Jest.Expect.invertedPartial('a)

But clearly wrote not_ as it suggests, not not__.

My attempted binding:

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

Thanks for any assistance. Just getting started with ReasonML ;)

glennsl
  • 28,186
  • 12
  • 57
  • 75

1 Answers1

1

Seems like this is caused by a largely undocumented change in Reason 3.3.4. I think it might hide in PR #2197.

not is a keyword in OCaml, which is why Expect.not_ is named such as it is in the first place. And this change seems to "mangle" (ie. translate) not in Reason into not_ in OCaml, and then not_ to not__ and so on.

So the solution is simply to replace all instances of not_ in your code with not. OR you can update bs-jest to 0.4.7 where I've added not__ as an alias to not_, so you can use either not or not_.

glennsl
  • 28,186
  • 12
  • 57
  • 75