Responses Expectations

toBeSuccessful()

Assert that the response has a successful status code.

expect(get('/page'))->toBeSuccessful();

toBeOk()

Assert that the response has a 200 status code.

expect(get('/page'))->toBeOk();

toBeNotFound()

Assert that the response has a not found status code.

expect(get('/unknown'))->toBeNotFound();

toBeForbidden()

Assert that the given response has a forbidden status code.

expect(get('/secret'))->toBeForbidden();

toBeUnauthorized()

Assert that the given response has an unauthorized status code.

expect(get('/admin-area'))->toBeUnauthorized();

toHaveNoContent()

Assert that the response has the given status code and no content.

expect(post('/timer/ping'))->toHaveNoContent();

toBeRedirect()

Assert that the given response is a redirection.

expect(get('/secret/location'))->toBeRedirect('/login');

toBeDownload()

Assert that the given response offers a file download.

expect(get('/reports/last.pdf'))->toBeDownload();

toHaveStatus()

Assert that the given response has a specific status code.

expect(post('/comment'))->toHaveStatus(201);

toRender()

Assert that the given response contains a string or array of strings.

expect(get('/page'))->toRender('<h1>title</h1>');

toRenderInOrder()

Assert that the given response contains an ordered sequence of strings.

expect(get('/page'))->toRenderInOrder(['<h1>title</h1>', '<h3>section</h3>']);

toRenderText()

Assert that the given response contains a string or array of strings in its text.

expect(get('/page'))->toRender('title');

toRenderTextInOrder()

Assert that the given response contains an ordered sequence of strings in its text.

expect(get('/page'))->toRenderInOrder(['title', 'content'], escape: false);

toContainText()

alias for toRenderText()

toContainTextInOrder()

alias for toRenderTextInOrder()

Edit this page on GitHub Updated at Fri, Oct 15, 2021