lundi 22 février 2021

Laravel Expected status code 200 but received 500

That's the code for my unit test, the default one:

<?php

namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class ExampleTest extends TestCase
{
    /**
     * A basic test example.
     *
     * @return void
     */
    public function testBasicTest()
    {
        $response = $this->get('/');

        $response->assertStatus(200);
    }
}

I'm running the laravel project on: php artisan serv

When I manually access the / the project works fine! however on the test I'm getting this error:

  Expected status code 200 but received 500.
  Failed asserting that 200 is identical to 500.

Here it is the full output:

  FAIL  Tests\Feature\ExampleTest
  ⨯ basic test

  ---

  • Tests\Feature\ExampleTest > basic test
  Expected status code 200 but received 500.
  Failed asserting that 200 is identical to 500.

  at tests/Feature/ExampleTest.php:19
     15▕     public function testBasicTest()
     16▕     {
     17▕         $response = $this->get('/');
     18▕ 
  ➜  19▕         $response->assertStatus(200);
     20▕     }
     21▕ }
     22▕

How can I fix that please?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3aKgeJn
via IFTTT

Aucun commentaire:

Enregistrer un commentaire