offline
anywhere

PlayBook📚

Writing your first Pest test in Laravel

GroundLiving
Automatically translated · View original (Nederlands)

Better code with fewer bugs starts with tests. Write and run your very first Pest test in Laravel.

2u

duration

Ground

pace

Tests zijn het vangnet van elke ontwikkelaar. Ze vangen fouten voordat je gebruikers ze zien. Pest is een testframework voor PHP, gebouwd op PHPUnit maar met een eenvoudigere, prettigere API. In Laravel is het zo opgezet dat je binnen een uur je eerste test draait.

Je installeert Pest via Composer, maakt een testbestand aan en schrijft een korte test die controleert of je welkomstpagina laadt. Daarna draai je hem vanuit de terminal. Groen betekent geslaagd, rood betekent werk aan de winkel. Vanaf die eerste groene balk kijk je nooit meer hetzelfde naar je code.

by PlayTryBe team

Install Pest in your Laravel project via Composer with composer require pestphp/pest --dev.

Create a test file in the tests folder and write a simple test that checks whether your welcome page loads with a 200 status.

Suggestion: Use it('loads the welcome page', ...) with an assertStatus(200).

Run your test from the terminal with ./vendor/bin/pest. Green means passed, red means there's something to fix.

For anyone copying this

Do as we did

PaceGround
Duration2u