我正在尝试开始使用 karma 和 Jasmine 。
我已经安装了它们。我相信 Karma 可以找到我的 JavaScript 文件。当我运行 karma start
时,我的浏览器打开并显示:
Karma v0.12.23 - connected
IE 11.0.0 (Windows 8.1) is idle
Firefox 29.0.0 (Windows 8.1) is idle
Chrome 37.0.2062 (Windows 8.1) is idle
我将一个 JavaScript 文件添加到我认为 Karma 正在监视的位置:
it('y should have a length of 1', function () {
var y = '1';
expect(y.length).toBe(0);
});
我在哪里可以看到单元测试失败?
如果我在 vs2013 中打开 resharper,我会看到单元测试。当我去运行它时,一个新的浏览器窗口打开,它是空白的。控制台确实显示在此页面上:
ncaught Error: jasmine.Suite() required
我怎样才能让它接受我的考试?
最佳答案
如 Jasmine 命名法 a suite 中所述
Suites: describe Your Tests
A test suite begins with a call to the global Jasmine function describe with two parameters: a string and a function. The string is a name or title for a spec suite – usually what is being tested. The function is a block of code that implements the suite.
所以我想您必须将测试包装在 describe 语句
describe('my test suite',function(){
it('my test case',function(){
//some assertions
})
});
关于javascript - 开始安装 Karma 和 Jasmine - jasmine.Suite() 需要错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26051001/