karma runner - In my Javascript Unit test, expect(true).toBeTruthy() fails - Stack Overflow

I do not understand how this is possible. I got this test from an example and it seems impossible for i

I do not understand how this is possible. I got this test from an example and it seems impossible for it to be failing, but it is:

expect(true).toBeTruthy();

.

PhantomJS 2.1.1 (Windows 7 0.0.0) Controller:TrivialCtrl should be truthy FAILED
    undefined is not a constructor (evaluating 'expect(true).toBeTruthy()')
    c:/Users/Donald/workspace/karma-trivial/spec.js:25:28

This is Karma with Chai, Mocha, and PhantomJS

I do not understand how this is possible. I got this test from an example and it seems impossible for it to be failing, but it is:

expect(true).toBeTruthy();

.

PhantomJS 2.1.1 (Windows 7 0.0.0) Controller:TrivialCtrl should be truthy FAILED
    undefined is not a constructor (evaluating 'expect(true).toBeTruthy()')
    c:/Users/Donald/workspace/karma-trivial/spec.js:25:28

This is Karma with Chai, Mocha, and PhantomJS

Share Improve this question asked Mar 23, 2016 at 3:43 Don SubertDon Subert 2,6766 gold badges30 silver badges37 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

The expect function is typically used with the chai assertion library: have you loaded this plugin?

You need to:

npm install chai karma-chai --save-dev

And add karma-chai to your list of plugins.

Additionally, reviewing the chai docs, I'm not sure if toBeTruthy is an operator: http://chaijs./api/bdd/.

You can however use ok:

expect(true).to.be.ok

I replaced

expect(match).toBeTruthy();

by traditional chai

expect(match).not.be.undefined;

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745443436a4627935.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信