use*_*366 6 unit-testing angular
我正在关注 angular 官方文档,我可以看到以下代码:
it("#getObservableValue should return value from observable", (done: DoneFn) => {
service.getObservableValue().subscribe(value => {
expect(value).toBe("observable value");
done();
});
});
Run Code Online (Sandbox Code Playgroud)
我想知道 DoneFn 来自哪里,因为我在输入时没有错误。
mch*_*l18 10
如果您遵循接口定义,您将看到它位于:
node_modules/@types/jasmine/index.d.ts
/** Action method that should be called when the async work is complete */
interface DoneFn extends Function {
(): void;
/** fails the spec and indicates that it has completed. If the message is an Error, Error.message is used */
fail: (message?: Error | string) => void;
}
Run Code Online (Sandbox Code Playgroud)
您不需要导入或使用它,它主要用于参考。我不确定到底是如何工作的,但我想如果项目中@types有一个打字,节点知道如何找到定义,因为它们都在这个文件夹中建立了索引。@types
更新:
我发现这是由配置的tsconfig.json
"typeRoots": [
"node_modules/@types"
],
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2316 次 |
| 最近记录: |