我在追踪
this tutorial from angular.io
正如他们所说,我创建了hero.spec.ts文件来创建单元测试:
import { Hero } from './hero'; describe('Hero',() => { it('has name',() => { let hero: Hero = {id: 1,name: 'Super Cat'}; expect(hero.name).toEqual('Super Cat'); }); it('has id',name: 'Super Cat'}; expect(hero.id).toEqual(1); }); });
单元测试像一个魅力一样工作。问题是:我看到一些错误,这在教程中提到:
Our editor and the compiler may complain that they don’t know what
it
andexpect
are because they lack the typing files that describe
Jasmine. We can ignore those annoying complaints for now as they are
harmless.
他们确实忽视了它。即使这些错误是无害的,但是当我收到这些错误的时候,我的输出控制台看起来并不好看。
我得到的例子:
Cannot find name ‘describe’.
Cannot find name ‘it’.
Cannot find name ‘expect’.
我可以做些什么来解决它?
我希望你已经安装 –
npm install –save-dev @ types / jasmine
然后将以下导入到hero.spec.ts文件的顶部 –
从茉莉花进口{}
应该解决问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。