Skip to content
Programing

Pest v4 Launch: Integrating AI Test Generation and Native Browser Support

Published: Duration: 6:07
0:00 0:00

Transcript

Host: Alex Chan Guest: Elias Thorne (Lead Developer and Pest Contributor) Host: Hey everyone, welcome back to Allur. I’m your host, Alex Chan, and today we are diving into something that has honestly changed the vibe of my workweek lately. You know that feeling when you’re about to ship a feature, but the thought of writing those last twenty edge-case tests feels like a mountain you just don't want to climb? Yeah, we’ve all been there. Testing has historically been the "homework" of the development world—necessary, but often a bit of a grind. Host: Joining me today is Elias Thorne. Elias is a Lead Developer at Synthetix and has been a frequent contributor to the Pest ecosystem for years. He’s been living and breathing the v4 beta and now the full release. Elias, it is so great to have you on Allur! Guest: Thanks so much, Alex! It’s awesome to be here. Honestly, I’ve been waiting for us to finally be able to talk about v4 in the wild. It’s been a wild ride since the March release. Host: I bet! I mean, the buzz has been incredible. Before we get into the "big" features like AI, I wanted to ask—what was your first reaction when you saw the direction Nuno and the team were taking with v4? Because it feels... more ambitious than just a version bump, right? Guest: Oh, absolutely. It’s a total shift. I think for a long time, the skeptics looked at Pest and said, "Oh, it’s just pretty syntax for PHPUnit." Which, okay, early on, sure. But v4 is Pest basically saying, "I’m the platform now." It’s opinionated, it’s aggressive about quality, and it’s trying to remove every single bit of friction. Like, remember setting up Selenium or even Dusk sometimes? It felt like you needed a PhD in infrastructure just to check if a button worked. Host: (Laughs) Oh, don't remind me. The "flaky test" nightmares! Guest: Exactly! And v4 is just... it's just *there*. It's all-in-one. Host: Well, let’s talk about the headline-grabber: Experimental AI Test Generation. I saw the `php artisan pest:ai` command and my jaw kind of dropped. How does this actually work in a real workflow? Is it actually smart, or is it just spitting out boilerplate? Guest: It’s actually surprisingly contextual. So, basically, it uses a mix of local and cloud LLMs to scan your actual implementation. If you point it at a Payment Service, it’s not just looking at function names. It’s seeing that you have a `try-catch` block for a `CardDeclined` exception, and it goes, "Hey, I should probably write a test for that." Host: Interesting! So it’s not replacing the developer, but it’s more like... a really fast intern? Guest: Precisely. I’ve started calling it "Shift-to-Editor" workflow. Instead of staring at a blank `it('does something')` block, I run the AI command, and it gives me 80% of the coverage. My job now is to look at it and say, "Actually, that mock is a little too simple," or "Oh, I forgot about that boundary condition, thanks AI." It removes that "boilerplate fatigue" that usually leads to people skipping tests when they’re in a rush. Host: I love that. It’s like the AI is the one doing the heavy lifting, and we’re the editors-in-chief. But what about the "magic" factor? Does it ever get things... well, wrong? Guest: Oh, definitely. It’s experimental for a reason. Sometimes it hallucinates a helper method that doesn't exist, or it doesn't quite grasp a complex business rule. But honestly, even when it's 10% wrong, it’s still 90% faster than me typing it all out. Host: That’s a fair trade. Now, let’s talk about the other big one: Native Browser Testing. For the longest time, if we wanted E2E (end-to-end) testing, we had to jump out of PHP and into Playwright or deal with the overhead of external drivers. Pest v4 claims to have built this into the core. How’s the stability been for you? Guest: This is the "aha" moment for me. The team built a native engine, so you literally just call `$this->browse()` inside your test. There’s no separate config file that’s 200 lines long. It feels just like writing a unit test. And the best part? When it fails, it takes a "state snapshot." Host: A snapshot? Like a screenshot? Guest: More than that! It gives you the screenshot, but also the console logs from the browser at that exact millisecond. You know those "flaky" tests that pass on your machine but fail in CI? Now you can actually see *why* the button wasn't clickable. It’s usually a race condition or a CSS transition, and v4 just hands you the evidence. It’s cut my debugging time for frontend tests in half, easily. Host: That sounds like a dream. I’ve spent way too many hours staring at GitHub Action logs trying to guess why a login failed. Now, I want to touch on something a bit more... let's say, "hardcore." Mutation Testing. It’s built-in now with `pest --mutate`. For someone who hasn't used it, why should they care? Guest: Okay, so this is the "ego check" for developers. (Laughs). You might have 100% code coverage, right? Your lines are all green. But mutation testing asks: "Are your tests actually *testing* anything?" Pest will go into your code and secretly change a `>` to a `>=` or change a `true` to a `false`. Then it runs your tests. Host: Oh! And if the tests still pass... Guest: Then your test is "weak." It’s an "escaped mutant." It means your test didn't catch a logic change. When I first ran it on one of my older projects, I thought I had bulletproof code. I ran `--mutate` and realized half my assertions weren't actually asserting anything meaningful. It’s brutal, but it makes your codebase incredibly resilient. Host: Wow. It’s like a stress test for your safety net. That’s actually a really powerful way to think about quality. It’s moving beyond "does it run?" to "is the architecture sound?" Guest: Exactly. And that ties into the Architecture Presets too. You can now just tell Pest, "Hey, I’m building a Laravel app," and it’ll automatically enforce rules like "Controllers shouldn't talk to the database directly." You don't even have to write the rules. It just knows. Host: It’s becoming very opinionated, isn't it? But in a way that feels helpful rather than restrictive. Guest: Right. It’s like having a senior architect sitting on your shoulder, but one who isn't annoying and actually helps you type faster. Host: (Laughs) I need that architect in my life! Elias, we’re almost out of time, but if there’s one piece of advice you’d give to someone who’s still on PHPUnit or an older version of Pest and is looking at v4, what would it be? Guest: Honestly? Just try the AI generation on one service class. Just one. See how it feels to have that structural scaffolding done for you. Once you see how much mental energy you save, there’s no going back. Testing stops being a chore and starts being... well, like Nuno says, joyful. Host: Joyful testing. Who would have thought? Elias, thank you so much for coming on and sharing your expertise. This has been eye-opening. Guest: My pleasure, Alex! Thanks for having me. Host: Of course! And to everyone listening, if you want to dive into the documentation or see some of those code examples Elias mentioned, check out the links in our show notes. Pest v4 is really setting the benchmark for what modern dev tools should look like.

Tags

llms open-source web development php testing laravel artificial intelligence