I created a route that functions OK, but my tests are unable to detect it. Since the test is of type feature, all Laravel features should be included.
I recently updated both my Composer and npm packages, including Laravel itself. Could this be the root cause of the problem?
Manipulating the closure to return a view or use a specific controller, clearing the cache, and dump autoload haven't resolved the issue.
Pest.php
pest()->extend(Tests\TestCase::class)
->use(Illuminate\Foundation\Testing\RefreshDatabase::class)
->in('Feature', 'Unit');
RouteTest.php
test('example', function () {
$response = $this->get('/');
$response->assertStatus(200);
});
web.php
Route::get('/', function () {
dd('Welcome!');
});
Test Error:
FAILED Tests\Feature\routes\ProjectRouteTest > example
Expected response status code [200] but received 404.
Failed asserting that 404 is identical to 200.
at tests/Feature/routes/ProjectRouteTest.php:6
2▕
3▕ test('example', function () {
4▕ $response = $this->get('/');
5▕
➜ 6▕ $response->assertStatus(200);
7▕ });
8▕
Tests: 1 failed (1 assertions)
Duration: 0.25s
Thank you in advance. I've been hung up on it for a while
dd(), while helpful for debug, doesn't return a 200 server response code. so the assert status on the response is correctly failing