You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Apparently, running the Dusk command from artisan, the browser has the language in Spanish, and Dusk from Composer, the browser has the language in English.
I do not know if it is simply a configuration error or if I am doing a wrong procedure.
The middleware:
public function handle(Request $request, Closure $next)
{
$language = $request->getPreferredLanguage(['en', 'es']) ?? 'en';
app()->setLocale($language);
return $next($request);
}
The Dusk test:
public function testBasicExample()
{
$this->browse(function (Browser $browser) {
$browser->visit('/')
->assertSee(trans('common.hello'));
});
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi guys, first of all, I am very thankful to you, because PHP is great since you created the Laravel framework.
I tell you that I am trying to do a simple test with Dusk and it is failing. The procedure is as follows:
When I run the Dusk command the test fails, so I created a script command in Composer to call the Dusk command and the test was successful. Summary:
Without Locale middleware:
php artisan dusk
-> successfulcomposer dusk
-> successfulWith Locale middleware:
php artisan dusk
-> Failcomposer dusk
-> successfulApparently, running the Dusk command from artisan, the browser has the language in Spanish, and Dusk from Composer, the browser has the language in English.
I do not know if it is simply a configuration error or if I am doing a wrong procedure.
The middleware:
The Dusk test:
The composer command:
I made a repository with the example code and put Logs to check the states of the Locale: https://github.com/barbosa89/dusky.
Beta Was this translation helpful? Give feedback.
All reactions