faraz73's avatar

Livewire works but test says: not !

Hi, I'm testing a livewire component , the test is error session should be thrown when from inputs are empty :

	/**
     * @test
     */
    public function while_creating_a_post_the_empty_inputs_should_return_errors()
    {
        Livewire::test('posts')
            ->set('title' , '')
            ->set('text' , '')
            ->call('store')
            ->assertSessionHasErrors(['title'=>'required','text'=>'required']);
    }

the error messages works in action but the test says: no error session has been set ..

0 likes
2 replies
tykus's avatar
tykus
Best Answer
Level 104

Try with the assertHasErrors method instead

public function while_creating_a_post_the_empty_inputs_should_return_errors()
  {
      Livewire::test('posts')
          ->set('title' , '')
          ->set('text' , '')
          ->call('store')
          ->assertHasErrors(['title'=>'required','text'=>'required']);
  }
1 like

Please or to participate in this conversation.