When running a post request inside a unit test,
$response = $this->post(route('teams.store'), ['name' => $teamName]);
it would throw an error saying
auth driver [jwt] for guard [api] not defined
For some reason, it appears that the service provider was not loaded that extends to include the JWT functionality. After I manually include
Tymon\JWTAuth\Providers\LaravelServiceProvider::class,
into config/app.php the unit test passes.
What is also important to mention is that when I run those same requests through Postman, I receive correct responses including the access_token.
Am I missing anything within my test suite?
Thanks for this awesome package!
| Q | A
| ----------------- | ---
| Bug? | yes (?)
| New Feature? | no
| Framework | Laravel
| Framework version | 6.1.0
| Package version | 1.0.5
| PHP version | 7.3.6
Encountered the same issue, after a bit of research it seems to be related to test config files being cached, files are located in bootstrap/cache:
Have a look here for further info :
https://github.com/laravel/framework/issues/13374
Personnaly, manually deleting those files and running tests again fixed the problem. Fixes are proposed in the thread
Thank you @jeremynikolic ! That was the solution to the problem
Most helpful comment
Thank you @jeremynikolic ! That was the solution to the problem