我已经开始使用 NestJS 并且有一个关于模拟单元测试的守卫的问题。我正在尝试测试一个基本的 HTTP controller
,它有一个方法 Guard 附加到它。
当我向 Guard 注入服务时,我的问题就开始了(我需要ConfigService
Guard 的服务)。
运行测试时,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) 我最近开始使用 NestJs 并在尝试使用TCP 客户端测试我的NestJs 微服务应用程序时获得了库存
是否可以触发@EventPattern
或@MessagePattern()
使用非嵌套应用程序?
尝试此方法时,套接字客户端只是停留在trying to connect
.
有任何想法吗?
谢谢。
Go 不支持 try-catch,相反,Go 错误处理的编码风格是在潜在的有效值旁边返回错误。如果错误符合,则错误将被设置为error
接口的实现,否则将被设置为nil
。
请参阅流动的签名:
func Open(name string) (file *File, err error)
Run Code Online (Sandbox Code Playgroud)
我想知道这个“错误处理”模式的名称是什么。
我正在尝试运行茉莉花助手脚本,但它们没有被拾取。我正在研究jasmine API,它看起来很简单,只需添加helpers
到jasmine.json
.
这是我正在测试的助手之一。它的唯一目的是在调用 jasmine 时创建一个文件。
助手/fileHelper.js
var fs = require('fs');
fs.writeFile("./jasmineHelperOutput.txt", "Hey there!", function(err) {
if(err) {
return console.log(err);
}
});
Run Code Online (Sandbox Code Playgroud)
茉莉花.json
{
"spec_dir": "./spec",
"spec_files": [
"**/*.spec.js"
],
"helpers": [
"helpers/**/*.js"
]
}
Run Code Online (Sandbox Code Playgroud)
设置:
但这不起作用。
我缺少什么?
我在https://github.com/dannyhuly/jasmine-with-helpers创建了一个简单的 jasmine 项目来解决当前的问题。
谢谢。
nestjs ×2
node.js ×2
go ×1
jasmine ×1
javascript ×1
jestjs ×1
mocking ×1
sockets ×1
unit-testing ×1