Everything has changed. End-to-end tests tooling is so much faster, it's so much cheaper than before that you don't have to write so many unit tests now. And you want your unit, you want your test to be as close to the user as possible. Usually your tests are not close to the user, they're close to the code. You want your tests to be closer to what the user is doing, so write those end-to-end tests. So if you want to call them integration tests or whatever, but make sure you're writing end-to-end tests.
If you can only have time to write one test, make it an end-to-end test. Keep PlayWrite up to date. So we release a new version of PlayWrite every month, and like, obviously we give you some really cool new features, and you're like, oh, maybe I don't need that feature, fine. But also like some bug fixes, and maybe like, I don't have any bugs, fine. But also, you're testing on the latest versions of the browsers, and you know, Chrome releases every month as well, right? So your browsers are being released every month. So by updating to PlayWrite, you're also testing against the latest browsers, and that's really, really important. So make sure you keep PlayWrite up-to-date, npm install dash d at playwrite slash test at latest.
Use locators. So locators come with the auto weighting and the retryability. And we highly encourage you to prioritize the user-facing attributes. So you'll see something like this page, get by role, what role am I looking for, I'm looking for the role of a button, and what is the name of that accessible role it is submit. And that is my user-facing attribute. I'm also testing that this button has a good accessible name. So you know, this is really good, because I'm testing accessibility. Plus I'm getting my test written and making sure my code is good. So I highly encourage you to use our playwright locators and user-facing attributes.
Use playwright assertions. So we talked about this before, they're auto retrying. So make sure you're using them. An example is a weight, make sure you have the weight, and then you expect, and you expect the page here, we're doing a get by test ID. And we've got the status, and we're expecting it to have the text submitted. So that's a playwright assertion to have text. And you'll see a whole list of those in the docs to have count, to have text, to be visible, etc.
Avoid testing third party dependencies.
Comments