Playing
01. Introduction and demo

Transcript

00:00
One option for testing Inertia apps is using end-to-end tests. These types of tests physically open a browser and interact with the page and this gives you the confidence that your application is working as expected, particularly when you have apps like Inertia-based apps where you're going to have lots of
00:19
JavaScript interactions. So to get started with end-to-end testing in Inertia, we're going to use the official Laravel Dusk package. This gives us a complete API for headlessly opening up a browser,
00:32
going ahead and interacting with elements and then of course performing assertions, making sure that things have gone the way that we want them to. There are other options like Cypress, but I've found Dusk the easiest to work with since it nicely integrates with Laravel.
00:47
Okay, let's take a look at a demo of the tests that we're going to be writing here and we're going to keep extending the course to add more. So to run our tests, we're going to use phpArtisan PEST and Dusk. Now when I run this, this is going to go through
01:01
and it's going to open up a browser. Obviously we can't see this at the moment and it's going to go through and we're going to see any failures, any things that have passed and then of course we'll get a nice summary at the end.
01:13
Now I've included a failing test in there. That's a little bit later when we're going to look at pushing this up to GitHub Actions, which we're also going to be covering in the course. So you can add this as part of your continuous integration flow.
01:26
But for now, let's go ahead and just look at what this looks like behind the scenes. So I'm actually going to go ahead and provide the browse option here. What this will do is it will open up a browser window and it will actually show us very, very slowly what the page is actually doing here.
01:40
So we're going through, we're creating tasks in this example application, we're deleting tasks, we're doing all sorts of things. That is generally going on behind the scenes unless we use the browse option. So in this course, we're going to cover 80% of what you need to know about Dusk
01:56
and we're going to slowly build up this task list application. Once we're done, you'll be able to start writing solid end-to-end tests for flows throughout your application that aren't possible with traditional feature or unit tests within Laravel.
02:11
We will be really careful and I'm going to give you a lot of advice that I have discovered along the way while writing end-to-end tests. We're going to make these tests super solid so they don't break if a piece of text changes or a button label changes on the page.
02:26
And we're also going to talk about probably when not to use end-to-end tests. So there's a lot to cover here, but let's get over to the first few episodes and the most important, which is setting up Laravel Dusk and making sure it's running and configured smoothly.
22 episodes2 hrs 53 mins

Overview

How do you test real flows through your Inertia applications? With end-to-end tests!

In this course, we’ll cover everything you need to know about setting up, writing and running browser-based tests. Once we’re done, we’ll configure CI (Continuous Integration) with GitHub Actions, to run your tests whenever you push new code.

Don’t use Inertia? No worries — there’s plenty to learn about end-to-end tests with Dusk in here too.

Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Episode discussion

No comments, yet. Be the first!