How to have testable Javascript in a Phoenix LiveView Project?

If the JS is written by your team, you can create sibling files to app.js that export testable public functions. Unit test those functions with a JS testing framework like vitest. If you want to test your JS’s integration with your backend, use an end-to-end testing framework like Wallaby or Playwright.

As a general rule, write unit tests that test “when [input], then [output]” for the all of the input cases your app needs to handle.

And if you do add end-to-end tests, only write tests for the happy path, as e2e tests are far slower and often have some flakiness to them, even when skilled people write them.

Happy testing!