小编Esr*_*lva的帖子

Nestjs 单元测试 - 模拟方法保护

我已经开始使用 NestJS 并且有一个关于模拟单元测试的守卫的问题。我正在尝试测试一个基本的 HTTP controller,它有一个方法 Guard 附加到它。

当我向 Guard 注入服务时,我的问题就开始了(我需要ConfigServiceGuard 的服务)。

运行测试时,DI 无法解析 Guard

  ? AppController › root › should return "Hello World!"

    Nest can't resolve dependencies of the ForceFailGuard (?). Please make sure that the argument at index [0] is available in the _RootTestModule context.
Run Code Online (Sandbox Code Playgroud)

我的力量失败守卫:

  ? AppController › root › should return "Hello World!"

    Nest can't resolve dependencies of the ForceFailGuard (?). Please make sure that the argument at index [0] is available in the …
Run Code Online (Sandbox Code Playgroud)

unit-testing dependency-injection mocking jestjs nestjs

9
推荐指数
2
解决办法
4952
查看次数

如何将命名方法传递给 Laravel 中的后备路由?

Laravel 路由中有一个后备方法:

Route::fallback(function () {
    //
});
Run Code Online (Sandbox Code Playgroud)

正常的路线是这样的:

Route::get('/user', 'UserController@list');
Run Code Online (Sandbox Code Playgroud)

有一种方法可以像这样使用后备路由:

Route::fallback('FallbackController@index');
Run Code Online (Sandbox Code Playgroud)

php laravel-5

3
推荐指数
1
解决办法
1744
查看次数