我不明白这是怎么可能的。我从一个例子中得到了这个测试,它似乎不可能失败,但它是:
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
这是带有 Chai、Mocha 和 PhantomJS 的 Karma
最佳答案
expect
函数通常与 chai
断言库一起使用:你加载了这个插件吗?
你需要:
npm install chai karma-chai --save-dev
并将 karma-chai
添加到您的插件列表中。
此外,查看 chai 文档,我不确定 toBeTruthy
是否是一个运算符:http://chaijs.com/api/bdd/ .
但是你可以使用ok
:
expect(true).to.be.ok
关于javascript - 在我的 Javascript 单元测试中,expect(true).toBeTruthy() 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36169439/