Compact Output Mode0:00
All right, it's time to take a look at the new features that come with Pest version 2, and there are a few really cool ones. But we're going to start simple. What we have now is a compact mode. So this means when we're running our test, we can add the flag --compact. And what this now does is it just outputs a dot and not the whole name of the test itself. Actually, if you have a lot of tests, this makes sense because the output in your console or in your log files or in your CI will be way less than before, like you can see here. Also something that you will see with the upgrade to PHPUnit 10 is that we're going to have to run phpunit with this flag here to migrate the configuration.
Profiling Slow Tests0:37
Also something that you will see with the upgrade to PHPUnit 10 is that we're going to have to run PHPUnit with this flag here to migrate the configuration. And I think now if we're going to run this again, we don't see this output by PHPUnit anymore. All right, so this is a very nice feature which you can use if you have a lot of tests and this makes a lot of sense. Then next to this, another one which I really like, let's take a look at is another flag, another --profile feature that's called profile. So what this does, it runs all your tests, but it also checks the performance of your test.
So what this does, it runs all your tests, but it also checks the performance of your test. And it's going to show us the 10 slowest tests, I believe. Let's try again and see what we get here as an output. Yes, we have this nice output here, the top 10 slowest tests. It shows the name of the test and then also the time. So for us, I would say that performance here is quite good already. We don't have too many tests. 80 is not that bad, but your performance more becomes an issue if you have like hundreds or thousands of tests.
80s is not that bad, but your performance more becomes an issue if you have like hundreds or thousands of tests. You can also see the time here, it's not too bad. 0.28 second is the slowest ones. And also these ones here, I think are all by ChatStream and Fortify. Let's see. Yeah, they're almost all by ChatStream and Fortify. Only this one is by us itself, which is also quite not that slow. I think it's all good. So I think in our case, we don't have to change anything.
Marking Tests as Todo2:08
I think it's all good. So I think in our case, we don't have to change anything. But it's really good if you come to a code base that you can check this. And sometimes there are one or two tests that are really bad for the performance of your whole test suite, and then it makes sense to take a look at how you can improve those tests here. All right, so this was profile. Then what we also have now, let's check this out. If I create now a new test, which is a to-do. So a test which I haven't yet done, which I haven't implemented.
If I create now a new test, which is a to-do. So a test which I haven't yet done, which I haven't implemented. So before we could just leave it empty, but what this does, let's check this out. It says that our test is risky. So I wouldn't really say that this test is risky. So besides that, we can also skip it by using the skip method here. Let's run this and you can see that it is skipped. By the way, with the phpStorm plugin for Pest, we also have this nice, a little cleaner output than before, which is also cool. But I also wouldn't say that this is a test we want to skip.
than before, which is also cool. But I also wouldn't say that this is a test we want to skip. Normally you have a skip test for a test which you have already implemented, but maybe there's some kind of issue and you want to skip this for some specific reason. But this, when we think about it, is a to-do, this is a test which we haven't done yet. So now with Pest version 2, we can also mark it as a to-do. And this gives us now this new to-do status for one of our tests, which is really nice. And if we're going to run all of our tests, you can also see that we have one to-do in here. I could have run the parallel testing, which would be easier.
here. I could have run the parallel testing, which would be easier. But yeah, here we see that we have one test, which is a to-do, and we also have now a to-dos flag here. So that only shows us the tests which are to-dos. And I think that's a very nice, simple, but still very convenient feature for your tests because sometimes we just have some tests that we haven't implemented yet and I'd like to mark them as to-dos because that's what they are. Okay, what else? There's one more thing that I would like to show you.
Retrying Failed Tests4:07
Okay, what else? There's one more thing that I would like to show you. For this, I have to change one of the tests to make it fail. Let's change this to assert ok. And if we now run all of our tests, let's do this again, we'll see that one is going to fail at some point here. So we have one fail test. So what I could do now is I could fix this, and then I would run all of the tests again because I don't really know which one it was. I could see it and I could go directly to the file.
because I don't really know which one it was. I could see it and I could go directly to the file. But yeah, sometimes I just want to run the command again to see if the failed one is still failing. In this case, it is. But what I can now also do in Pest version 2 is use the retry method. And now this only runs the file where we have the failing test, which is our PageResponsesTest. I think this is pretty useful because you run your test suite, maybe one other test is failing because of something you don't know yet.
I think this is pretty useful because you run your test suite, maybe one other test is failing because of something you don't know yet. You want to fix this and you want to run this test again, just this one to make sure that this is working. And then later you can run all of the other tests and your whole test suite again. But I think this is a very useful feature, which I already see myself using quite often. Yeah, so these are the main features. We have the compact version, we have the profile flag, we have the to-do flag, we have to-dos in general, we have the retry flag. So a few more little features which help you to work, we're working on your test and it's
Recap and Next Plugin5:39
in general, we have to retry flag. So a few more little features which help you to work, we're working on your test and it's just a little more convenient, it's a little bit nicer and some more developer experience, which we gained here. Pest 2 comes with just one more cool plugin, which I want to show you, but we're going to do this in the next video.
