Pest released v3.5 with support for nested describe() blocks in tests! You can now group related tests inside a parent describe() block, giving you more flexibility in organizing things.
big news: just dropped pest 3.5.0, and it now supports nested describe blocks. happy tuesday, let’s go! 🤌🻠pic.twitter.com/AN2IRJL0pW
— Nuno Maduro â˜ï¸ 🦹 (@enunomaduro) October 22, 2024 <script async src=”https://platform.twitter.com/widgets.js” charset=”utf-8″></script>
Before this release, you could use the describe() block for group tests; however, you could only do so at the top level of your test file. For example, lets say you want to group all your admin dashboard feature tests together. Before, you might group them in separate top-level describe() blocks, but now you can call describe() inside another describe() like so:
describe(‘Dashboard’, function () {
beforeEach(fn () => $this->actingAs($this->user));
describe(‘Notifications’, function () {
test(‘new notifications are displayed’, function () {
// …
});
test(‘cleared notifications are no longer visible’, function () {
// …
});
});
describe(‘New orders’, function () {
test(‘orders made within the last 24 hours are visible’, function () {
// …
});
});
});
Here’s what the output of those grouped tests looks like when you run the test suite. Notice the clean organization of tests:
Update to the latest version to get nested describe blocks as well as all the amazing features available in the release of Pest 3.
Shout out to Justin Hayes, who contributed this support for nested describe blocks in Pull Request #1295!
The post Nested Describe Blocks Are Now Available in Pest v3.5 appeared first on Laravel News.
Join the Laravel Newsletter to get all the latest
Laravel articles like this directly in your inbox.
Source: Read MoreÂ