Laravel8 tdd: session is missing expected key errors

  laravel, laravel-8, laravel-testing, php

I just want to test an easy input field but I get this error!

enter image description here

/** @test */
public function email_must_be_a_valid_email()
 {
   $response = $this->post('/api/contacts', array_merge($this->data(), ['email' => 'NOT AN EMAIL']));
   $response->assertSessionHasErrors('email');
 }


private function data()
{
  return [
          'name' => 'Test Name',
          'email' => '[email protected]',
          'birthday' => '05/14/1988',
          'company' => 'ABC String'
        ];
}

I hope u can help me with it.

Source: Laravel

Leave a Reply