小编mae*_*lga的帖子

Laravel dusk:使用 Dropzone.js 测试文件上传

我正在使用 laravel5.6Dusk进行此特定测试。

我正在尝试在我的 dropzone 中声明文件上传。但是我的 Dropzone 是以我没有file输入元素的方式创建的。所以我不能使用该attach()方法。

所以我尝试了以下

$file = new \Symfony\Component\HttpFoundation\File\UploadedFile(base_path() . '/tests/samples/Cylinder.stl', 'Cylinder.stl');

$response = $this->actingAs( $this->user )
                ->from( 'my-url' )
                ->post( route('attachments.store' ) , [
                    'file' => $file
                ]);
Run Code Online (Sandbox Code Playgroud)

但是错误包包含这个错误

"errors" => Illuminate\Support\ViewErrorBag {#1194             
  #bags: array:1 [                                             
    "default" => Illuminate\Support\MessageBag {#1189          
      #messages: array:1 [                                     
        "file" => array:1 [                                    
          0 => "The file failed to upload."                    
        ]                                                      
      ]                                                        
      #format: ":message"                                      
    }                                                          
  ]                                                            
}      
Run Code Online (Sandbox Code Playgroud)

当然,当我手动执行时,这是有效的。

testing laravel laravel-dusk

2
推荐指数
1
解决办法
1372
查看次数

标签 统计

laravel ×1

laravel-dusk ×1

testing ×1