Mar 21, 2026
0
Level 63
Pest browser testing for forms with a file upload
Hello,
I'm writing browser tests with Pest.
I have a form to update the profile name of the current user.
test('user can edit his/her profile', function () {
$this->actingAs($this->user);
$page = visit('/profile')->on()->desktop()->wait(2);
$page
->assertSee($this->user->name)
->click('@edit-profile')
->type('name', 'Vincent')
->press('Enregistrer')
->assertSee('Vincent')
->assertNoJavascriptErrors();
});
The test fails because it sends a POST request to the server instead of a PUT request. For all other forms (I mean without any file upload), the test is successful when updating a model.
Testing manually in the browser, it works fine. It's just the Pest test that fails.
Any idea ?
Thanks for your help.
V
Please or to participate in this conversation.