fable-compiler / Fable.Lit

Write Fable Elmish apps with Lit
https://fable.io/Fable.Lit/
MIT License
91 stars 13 forks source link

Convert tests to F# #13

Closed alfonsogarciacaro closed 2 years ago

alfonsogarciacaro commented 2 years ago

@AngelMunoz I wanted to have a better testing story in F# before the "official" release so I've tried to convert the tests to F#. For now, I've put the helpers in this repo, but it probably makes sense to create a different package as it can help Fable devs with other projects. At the beginning I tried to write some bindings for chai, but the API is not very idiomatic in F# and it doesn't use F# equality either, so I've written a simple assertion library. Besides that, I extracted some bits from testing-library so we can make accessible queries (for now, getByRole and getByText).

Please have a look if you have a moment and let me know what you think :)

AngelMunoz commented 2 years ago

Looks great! I think we can improve the testing library over the time, I won't deny the tests look good in F#

alfonsogarciacaro commented 2 years ago

Cool! I was trying to add some React tests to make it more generally helpful, but Web Test Runner complained when loading the React dependency. So for now let's just include it within the Lit packages as Lit.Test.

On the other hand, I managed to remove the @open-wc/testing dependency, so users only need @web/test-runner to run the tests. When rendering you get a disposable wrapper compatible with F# use!. There's a minor inconvenience that you don't get direct access to the element, you need to do wrapper.El but I hope that's ok.

alfonsogarciacaro commented 2 years ago

Cool! I was trying to add some React tests to make it more generally helpful, but Web Test Runner complained when loading the React dependency. So for now let's just include it within the Lit packages as Lit.Test.

On the other hand, I managed to remove the @open-wc/testing dependency, so users only need @web/test-runner to run the tests. When rendering you get a disposable wrapper compatible with F# use!. There's a minor inconvenience that you don't get direct access to the element, you need to do wrapper.El but I hope that's ok.