Something that makes your end-to-end tests a heck of a lot more resilient is mocking your API so you're not hitting the network, and so your API responses are deterministic. Doing that also makes the tests run a lot faster. MSW is my preferred library for doing that, and there's a Playwright integration (https://www.npmjs.com/package/playwright-msw).
Mocking the API makes it really easy to response with failures too - having a test that checks the app handles a 500 error or a 401 Unauthorized is really useful, and a total pain to do without mocks.
You can test the API is working and returning what you'd expect with a different set of tests. :)
We had this discussion at work too, and decided it was worth keeping our e2e tests e2e (no mocking, pointing the UI code at our integration environment). However, I think there's value in also having a set of tests that do mock the dependencies while testing UI flows because of how long it takes to run the real e2e tests. so "both" is the dream, with e2e tests being more critical.
Yes you can. Our tests are layered as follows:
- unit tests
- mocking tests
- integration tests (i.e. service + db)
- system tests (full api to db level)
integration starts providing flaky tests already sadly, i.e. with kafka on our end… (i.e. calling the listener twice or thrice even tho it should only once..)
It's hard to name them I suppose. They're more than just UI tests because there's usually a decent amount of logic in the frontend apps I build (significantly more than just driving the UI), so I call them end-to-end or integration tests.
Looks like it is back for some users, but not others. Probably just the time it takes to propagate the DNS. What a bummer! Thank you for helping to troubhelshoot
Mocking the API makes it really easy to response with failures too - having a test that checks the app handles a 500 error or a 401 Unauthorized is really useful, and a total pain to do without mocks.
You can test the API is working and returning what you'd expect with a different set of tests. :)