Jasmine 2 Spec has no expectations

1k Views Asked by At

I have the following test:

describe('when invoked', function() {
  it('should check something', function() {
    _.each(someData, function(obj, index) {
      expect(obj[index].lable).toBe('foo');
    });
  });
});

When I run Jasmine 2.2.0 it get the following error:

Spec 'SpecLabel function when invoked return value should check something' has no expectations.

Am I missing something? In Jasmin 1.x we could do this. Have expect inside a for each, or even a for loop.

How can I fix these type of tests? And what are the docs for these situations? The Jasmine website is not really helpful.

1

There are 1 best solutions below

0
On

A quick workaround can be refactoring your tests to:

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();
    });
});