RaduM
RaduM

Reputation: 2609

Jasmine 2 Spec has no expectations

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.

Upvotes: 1

Views: 1041

Answers (1)

user1253128
user1253128

Reputation: 61

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

Upvotes: 1

Related Questions