composer require markhuot/craft-pest --dev
./craft pest/test
Handles the setup and installation of Pest in to Craft CMS. This allows you to write tests that look something like this!
it('loads the homepage')
->get('/')
->assertOk();
it('has a welcoming h1 element')
->expect(fn() => $this->get('/'))
->querySelector('h1')->text->toBe('Welcome');
it('asserts nine list items')
->get('/')
->querySelector('li')
->assertCount(9);
it('expects nine list items')
->expect(fn() => $this->get('/'))
->querySelector('li')
->count->toBe(9);
it('promotes craft')
->get('/')
->assertHeader('x-powered-by', 'Craft CMS');
it('shows news on the homepage', function() {
$titles = News::factory()->count(3)->create()->title;
expect($this->get('/')->querySelector('.news__title'))
->count->toBe(3)
->text->sequence(...$titles);
});