Ste*_*che 0 node.js typescript jestjs visual-studio-code
我在使用Jest进行测试的Typescript项目中使用VS Code。由于某些原因,VS Code认为Jest全局变量不可用:
我的开发依赖项中安装了Jest typedef。
"devDependencies": {
// ...truncated
"@types/jest": "^20",
"jest": "^20.0.4",
"ts-jest": "^20.0.7",
"ts-node": "^5.0.0",
"typescript": "~2.4.0"
}
Run Code Online (Sandbox Code Playgroud)
正确的答案是,打字稿要求jest进行类型声明,然后才能在jest全局对象中看到intellisense。
将此三斜杠指令添加到测试文件的开头:
/// <reference types="jest" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1541 次 |
| 最近记录: |