Luckily, things got a lot better. Puppeteer was the first step for official browser automation, backed by Google for Chrome, and then Cypress a few years ago appeared with solid developer experience, and you might have guessed it, for a long time now, I'm playing around with Playwright, and I think it's just a very, very decent solution for end-to-end testing.
So, let me show you what Playwright is about. In case you haven't seen Debbie's talk, so first of all, Debbie from the Playwright team talked about Playwright just a few moments ago. Playwright is a very inclusive testing solution. So, it includes all major browsers, covering Chromium, WebKit, and Gecko Firefox. It runs on Mac, Windows, and Linux, and you can write tests primarily in JavaScript and TypeScript. If .NET, Python, and Java are your kind of thing, you can do that, too. So, from an inclusivity standpoint, Playwright is top-notch. Additionally, if VS Code is your editor of choice, the VS Code Playwright extension plays very nicely to create Playwright tests, debug them, generate them, run them. You can do all this end-to-end functionality and testing functionality right from your editor. If this is your jam, you can use VS Code, so that is very nice.
And it took me a while to realize that Playwright is actually more than a browser control. Playwright Test, these days, is a full-fledged testing framework that comes with the usual describe functionality, before each, after each hooks, fixtures, test configuration. All these goodies are included in Playwright itself. So when you want to really go all-in on end-to-end testing, Playwright is a valuable solution here. It's easy to paralyze. So remember my story of running tests and waiting for 30, 40 minutes? With Playwright, you can paralyze all your tests with a single CLI argument or put it in your configuration to speed up what happens and what is going on. And by far, my favorite is that Playwright is built for quick execution with features such as auto-waiting and web-first assertions, because UI testing is usually that, well, you wait for something, you do something with it and then you wait for the next thing to appear to do something with it then. And usually this means that I had to put arbitrary delays here and there or manually wait for elements to appear or disappear. Playwright has all of this baked in and this gets me very excited. Debbie briefly touched on this, but I want to show you how this works in this session too. So, shall we have a look? Let's have a look at Playwright and run some tests. So, we go to VS Code and what you see here is on the right side my terminal. And on the left side, we have test.js spec.js file, which is a standard test file. And what we will test is this lovely website here, which is on localhost 8080. And it's the test.js summit site and it's pretty much the same side, but now it includes this huge celebrate button, because I think more websites should have confetti in them. Other than that, when we look at the project configuration of the project setup here, you will find a standard playwright config here and other than that, there's a test folder including test.js spec.js and this little facebomb.js is just my notes here in case you're wondering that. We're not using the VSCode extension here, so to run this project and run the tests that are included in it, what you can do is npx playwright test and you see already that there are 28 discovered tests using five workers and we see already parallelization going on here, but we're going to have a look at what happens here right now. We see that there are seven past tests and 21 skipped and when we look at the test file, we see that there's one official or enable test and the other three are skipped, but why is everything multiplied by seven? So when we go to the playwright config, you will see that right now there are various and multiple browsers configured to be run when we run playwright tests.
Comments