Marcel
Marcel

Reputation: 4402

Why is angularjs expect don't working?

I tried to write the simplest possible javascript unit test with angular.js but it fails and I don't know why.

test.html

<html>
  <head>
    <script src="angular-1.2.21/angular-scenario.js" ng-autotest></script>
    <script src="test1.js"></script>
  </head>
</html>

test1.js

describe('A suite', function() {
  it('should be true', function() {
    expect(5).toBe(5);
  });
});

I deploy both files (and libs) on server and call the html site. The tests runs but always fails with

expected undefined toBe 5 but was undefined

What am I missing?

Upvotes: 0

Views: 84

Answers (2)

V31
V31

Reputation: 7666

From the information that you have given I think you have not included the jasmine file

http://searls.github.io/jasmine-all/jasmine-all-min.js

Tried your code after including this and it is working fine.

Here is a working fiddle

Upvotes: 1

basarat
basarat

Reputation: 276085

I think the syntax is wrong. Try:

 expect(5).to.equal(5);

REF: http://chaijs.com/api/bdd/

Upvotes: 0

Related Questions