简体   繁体   English

使用WebStorm测试Angular JS:未解决的函数或方法inject()

[英]Testing Angular JS with WebStorm: unresolved function or method inject()

I'm developing web an app using AngularJS + TypeScript, and Karma + Jasmine for testing purposes. 我正在开发一个使用AngularJS + TypeScript和Karma + Jasmine进行测试的Web应用程序。

The problem is that WebStorm continues pestering me with the following error, despite the fact that all of my tests compile well: 问题是,尽管我的所有测试都可以很好地编译,但WebStorm仍然用以下错误困扰着我:

Unresolved function or method inject() 未解决的函数或方法inject()

在此处输入图片说明

I've added angular-mocks typings: 我添加了角度模拟输入:

在此处输入图片说明

and provided angular-mocks JavaScript library for IDE: 并为IDE提供了angular-mocks JavaScript库:

在此处输入图片说明

But the problem still exists. 但是问题仍然存在。 I know that as a workaround, one can declare corresponding variable, but honestly I don't really think that this is a good approach. 我知道作为一种解决方法,可以声明相应的变量,但是老实说,我并不真的认为这是一种好方法。

Works fine for me using typings ( npm i @types/angular-mocks ): 使用打字对我来说很好用( npm i @types/angular-mocks ):

在此处输入图片说明

Please try invalidating caches 请尝试使缓存无效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM