Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/377.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Jasmine 2规范没有任何期望_Javascript_Unit Testing_Testing_Jasmine_Grunt Contrib Jasmine - Fatal编程技术网

Javascript Jasmine 2规范没有任何期望

Javascript Jasmine 2规范没有任何期望,javascript,unit-testing,testing,jasmine,grunt-contrib-jasmine,Javascript,Unit Testing,Testing,Jasmine,Grunt Contrib Jasmine,我有以下测试: describe('when invoked', function() { it('should check something', function() { _.each(someData, function(obj, index) { expect(obj[index].lable).toBe('foo'); }); }); }); 当我运行Jasmine 2.2.0时,会出现以下错误: Spec“调用SpecLabel函数时,返回值应检

我有以下测试:

describe('when invoked', function() {
  it('should check something', function() {
    _.each(someData, function(obj, index) {
      expect(obj[index].lable).toBe('foo');
    });
  });
});
当我运行Jasmine 2.2.0时,会出现以下错误:

Spec“调用SpecLabel函数时,返回值应检查某些内容”没有期望值。

我错过什么了吗?在Jasmin1.x中,我们可以这样做。在for-each甚至for循环中使用expect


如何修复这些类型的测试?这些情况下的文档是什么?Jasmine网站并没有真正的帮助。

一个快速的解决方法是重构您的测试,以:

describe('when invoked', function () {
    it('should check something', function () {
        var success = true;
        _.each(someData, function (obj, index) {
            success &= obj[index].lable === 'foo';
        });
        expect(success).toBeTruthy();
    });
});