How to add Sinon to angular 2 testing?

此生再无相见时 提交于 2019-12-10 18:26:58

问题


I want to add Sinon for testing but I can't get it to run.

I've installed sinon and karma-sinon as DevDependencies.

added sinon to Frameworks in my karma config file.

 frameworks: ['jasmine', 'browserify','sinon'],

and in my test file I'm trying to declare a spy

let setTokenSpy = sinon.spy(sbHttpObiject, 'checkForToken');

and I'm getting

TypeScript error: app/sdk/test/http.spec.ts(87,22): Error TS2304: Cannot find name 'sinon'.

Any help much appreciated! Btw, i think jasmine has also spies but i can't get them to run either, any updates on that?

EDIT---------------------------- ---------09.09.2016

meanwhile i've found out that I need to install typings like

typings install dt~sinon --save --global

But now I'm getting this error

ReferenceError: Can't find variable: sinon in /var/folders/ld/2g86bbq11tddvbnzlzbtg2r80000gn/T/78dc4c45b42a2dd7bfcfb607366d1d15.browserify (line 350)

来源:https://stackoverflow.com/questions/39329300/how-to-add-sinon-to-angular-2-testing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!