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

Is JestDom.expect compatible/interchangeable with Jest.Expect.expect? #18

Open
jihchi opened this issue May 1, 2020 · 2 comments
Open

Comments

@jihchi
Copy link
Contributor

jihchi commented May 1, 2020

bs-jest-dom: 4.0.0

For example, add following test case:

test("Jest.Expect.toEqual", () =>
  "Foo" |> expect |> Jest.Expect.toEqual("Foo")
);

to the file after line 480:

test("not toBeChecked", () =>
render({|<input type="checkbox" data-testid="input" />|})
|> queryByTestId("input")
|> expect
|> not_
|> toBeChecked
);

save and run yarn test, you will get following error:

  We've found a bug for you!
  /Users/jihchi/Repos/bs-jest-dom/src/__tests__/JestDom_test.re 483:12-17

  481 │ 
  482 │ test("Expect.toEqual", () =>
  483 │   "Foo" |> expect |> Expect.toEqual("Foo")
  484 │ );

  This has type:
    JestDom.t => JestDom.expect
  But somewhere wanted:
    string => 'a

  The incompatible parts:
    JestDom.t (defined as
      Dom.eventTarget_like(Dom._node(Dom._element(Dom._baseClass))))
    vs
    string

Is that expected?

@jihchi
Copy link
Contributor Author

jihchi commented May 1, 2020

By the way, there is a work-around by changing expect to Expect.expect:

test("Expect.toEqual", () =>
  "Foo" |> Expect.expect |> Expect.toEqual("Foo")
);

@wyze
Copy link
Owner

wyze commented May 1, 2020

I don't think they are compatible because I have typed it to only be called on DOM elements. I don't think there is a way for us to use each interchangeably. Open to any suggestions for improvements.

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