升级后,Mocha甚至无法运行这里的简单测试代码
const assert = require('assert');
it('should complete this test', function (done) {
return new Promise(function (resolve) {
assert.ok(true);
resolve();
})
.then(done);
});
Run Code Online (Sandbox Code Playgroud)
我从这里拿了这个代码
我明白它现在抛出异常 Error: Resolution method is overspecified. Specify a callback * or * return a Promise; not both.
但是如何让它发挥作用?我不明白.我有
node -v 6.9.4
mocha -v 3.2.0
Run Code Online (Sandbox Code Playgroud)
如何运行此代码现在采用新的正确格式?
我在我的角度应用程序中有标准工厂用于休息api.我需要使用GraphQl为api配置我的角度应用程序.我怎么能这样做?我现在关于 angular2-apollo,但我有角度1.5.
当工作完成时,我试图抓住一个事件
测试代码:
class MyTest extends TestCase {
public function testJobsEvents ()
{
Queue::after(function (JobProcessed $event) {
// if ( $job is 'MyJob1' ) then do test
dump($event->job->payload());
$event->job->payload()
});
$response = $this->post('/api/user', [ 'test' => 'data' ], $this->headers);
$response->assertSuccessful($response->isOk());
}
}
Run Code Online (Sandbox Code Playgroud)
UserController中的方法:
public function userAction (Request $request) {
MyJob1::dispatch($request->toArray());
MyJob2::dispatch($request->toArray());
return response(null, 200);
}
Run Code Online (Sandbox Code Playgroud)
我的工作:
class Job1 implements ShouldQueue {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $data = [];
public function __construct($data)
{
$this->data= $data;
}
public function handle() …Run Code Online (Sandbox Code Playgroud) 我有具有关系语言的雄辩模型用户
class User extends Model {
// ... some code
public function languages()
{
return $this->belongsToMany(Language::class);
}
}
Run Code Online (Sandbox Code Playgroud)
我的多对多关系的迁移数据透视表
public function up()
{
Schema::create('language_user', function (Blueprint $table) {
$table->unsignedInteger('user_id');
$table->unsignedInteger('language_id');
$table->primary(['user_id', 'language_id']);
});
}
Run Code Online (Sandbox Code Playgroud)
在控制器中我尝试获取我的用户
class UserController extends Controller
{
public function show(User $user)
{
return response()->success($user->with('languages')->get());
}
}
Run Code Online (Sandbox Code Playgroud)
但不幸的是,我得到的不是一个用户,而是用户的结果数组, 我如何才能只查询一个用户的语言记录?