angularjs – 如何从用于编写在Typescript中的测试中导入jasmine的’createSpyObj’?

前端之家收集整理的这篇文章主要介绍了angularjs – 如何从用于编写在Typescript中的测试中导入jasmine的’createSpyObj’?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何从jasmine导入createSpyObj属性? @H_404_7@

@H_404_7@我通过npm安装了@ types / jasmine和jasmine-core.

@H_404_7@我尝试将茉莉花导入:

@H_404_7@

import jasmine from 'jasmine;
import { createSpyObj } from 'jasmine'; //triggers import error in IDE
import * as jasmine from 'jasmine'; //triggers import error in IDE
@H_404_7@这些都不允许我访问createSpyObj而没有在我的WebStorm IDE中抛出错误.

@H_404_7@

IDE error showing it cannot find 'createSpyObj' method on jasmine

@H_404_7@更多信息:

@H_404_7@我在typings文件中看到了createSpyObj的命名空间声明.它嵌套在jasmine名称空间中.这与期望不同,它是全局声明,但我不能用jasmine.createSpyObj访问它吗?

@H_404_7@

jasmine typings file

@H_404_7@相关,但不重复

@H_404_7@How to import ‘describe’,‘expect’ and ‘it’ into a typescript tests for IDE to not to highlight them

@H_404_7@Unit testing using Jasmine and TypeScript

解决方法

jasmine使用require语法,所以你也必须这样做. @H_404_7@

@H_404_7@

import createSpyObj = jasmine.createSpyObj;

猜你在找的Angularjs相关文章