0

I am starting to use PEST in my Laravel-project. I started to read the documentation and saw that both assert and expect exists but I see no real explanation on their difference.

Can someone please tell me the difference and when to use what?

Brainmaniac
  • 2,203
  • 4
  • 29
  • 53
  • 1
    Does this answer your question? [What is the difference between “assert”, “expect”, and “should” in Chai?](https://stackoverflow.com/questions/21396524/what-is-the-difference-between-assert-expect-and-should-in-chai) - They talk about another framework/language, but the basic idea is most likely be the same. – M. Eriksson Dec 27 '22 at 19:25
  • I don't think that is adequately accurate. AFAIK there is no should in PEST and I don't KNOW if it is the same difference between assert and expect in the framework you linked as in PEST. I know sometimes there is the difference that asserts aborts at first failure while expect continues and gives you all fails, but again, I don't KNOW – Brainmaniac Dec 27 '22 at 19:33
  • Looking at PEST's documentation/usage of assert vs expect and then reading the answers for that question, I don't really see any difference, tbh. Don't overthink it. Use what makes sense to make your code tested to the extent you need it to be (which rarely means that you need to test every line, every function using every testing methodology known) – M. Eriksson Dec 27 '22 at 19:35
  • No, I am continuing working (only using expect lol) thought I'd ask to see if someone actually knew. – Brainmaniac Dec 27 '22 at 19:45
  • 1
    @Brainmaniac I have never used Pest as I do not see any real advantage, but checking on both links you shared, the only difference is just grammatical, you can se with `expect` you can write it like in a "fluent" human way, just that – matiaslauriti Dec 27 '22 at 21:08

0 Answers0