在Laravel Dusk中断言状态

时间:2019-03-22 10:14:01

标签: laravel laravel-dusk

我有一个测试可以验证状态。应该是200

当我运行这个

public function testBasicTest()
{
    $response = $this->json('GET', '/');
    $response->assertStatus(200);
}

它通过了,但是当我添加网址时:/ clients 始终状态404

public function testBasicTest()
{
    $response = $this->json('GET', '/clients');
    $response->assertStatus(200);
}

Error: 
Expected status code 200 but received 404.
Failed asserting that false is true.

2 个答案:

答案 0 :(得分:0)

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');

});

答案 1 :(得分:0)

按如下所示更改您的route.php。我在ti中添加了/ clients路由。

<?php


   Route::get('/', function () {
      return view('welcome');

   });

   Route::get('/clients', function () {
      return view('welcome');

   });