Oct 4, 2021
0
Level 16
Set headers during laravel dusk testing
I am testing locales for my current project. Unfortunaltey, I am unable to pass headers during a dusk browser tests. Tried searching a whole lot but coundn't find a solution. Please suggest.
$this->browse(function (Browser $browser) {
// need to pass headers here. e.g. mysite-locale = en-us then expect the cookie value to be 'en-us'
$browser->visit(config('app.url'));
$this->assertEquals($browser->plainCookie('mysite-locale'), 'en-ca');
});
On one of our services, the languages is set based on Accept-Language ... $this->request->header('Accept-Language'). Hence the need to set headers during dusk tests.
Please or to participate in this conversation.