To access the session data in Laravel Dusk tests when running on GitHub Actions, you need to make sure that the session is properly initialized. Here's a solution you can try:
- In your Dusk test file, add the following line at the top to import the
Sessionfacade:
use Illuminate\Support\Facades\Session;
- Before accessing the session data, make sure to start the session by calling the
startSessionmethod. You can do this in thesetUpmethod of your Dusk test class:
protected function setUp(): void
{
parent::setUp();
Session::start();
}
- Now you should be able to access the session data using the
session()helper function or theSessionfacade. For example:
if (session()->has('value')) {
// Your code here
}
Make sure to update your Dusk test file with these changes and run the tests again on GitHub Actions. This should enable access to the session data.
Note: If you're using Laravel 8 or later, you may need to install the symfony/dom-crawler package to use the Session facade. You can install it via Composer:
composer require symfony/dom-crawler
Let me know if you have any further questions!