[Bug]: visit()->on()->desktop() only works when fully chained; fails when stored and used later
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 11.7k
- Forks
- 538
- Avg merge
- 4d 11h
- Merged PRs (30d)
- 8
Description
What Happened
In Pest Browser tests, using on()->desktop() and storing the page in a variable (then calling interaction methods later like ->type() or ->fill() doesn’t behave like a single chained call, the page is reinitialized and a new tab/window gets opened on each interaction.
How to Reproduce
Use the attached minimal repo (Laravel + Pest + pest-plugin-browser).
Run only the browser login tests:
php artisan test --filter="LoginTest"
Observe:
These pass:
it('logs a user in via the login screen', function () {
$user = User::factory()->create();
$page = visit(route('login'));
$page->fill('email', $user->email);
$page->fill('password', 'password');
$page->press('Log in');
$this->assertAuthenticated();
$page->assertUrlIs(route('dashboard'));
});
it('logs a user in when on()->desktop() is applied in a single method chain', function () {
$user = User::factory()->create();
$page = visit(route('login'))
->on()->desktop()
->fill('email', $user->email)
->fill('password', 'password')
->press('Log in');
$this->assertAuthenticated();
$page->assertUrlIs(route('dashboard'));
});
This fails:
it('logs a user in when on()->desktop() is applied then reused later (non-chained)', function () {
$user = User::factory()->create();
$page = visit(route('login'))->on()->desktop();
$page->fill('email', $user->email);
$page->fill('password', 'password');
$page->press('Log in');
$this->assertAuthenticated();
$page->assertUrlIs(route('dashboard'));
});
Sample Repository
https://github.com/falfox/pest-browser-repro
Pest Version
4.0.4
PHP Version
8.4.11
Operation System
Linux (WSL2)
Notes
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running php artisan test --filter="LoginTest" in the attached Laravel and Pest reproduction, comparing the chained and stored uses of visit()->on()->desktop(). Trace the visit(), on(), and desktop() entry points; done means later fill() and press() calls reuse the same page without opening new tabs, and the login assertions pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- laravel, php
- Domain
- testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100