TypeError: 'undefined' is not a function (evaluating 'sinon.spy()')

Viewed 11504

I'm trying to use sinon.js in testing of a backbone application. But unfortunately I cannot use spy method due to error:

TypeError: 'undefined' is not a function (evaluating 'sinon.spy()')

Here is the steps to reproduce the error:

  1. Create an empty project with backbone yeoman generator
  2. Install sinon: cd test && bower install sinon
  3. Include in test/index.html <script src="bower_components/sinon/lib/sinon.js"></script>
  4. Create spy in test/spec/test.js:

    describe('Give it some context', function () {
        describe('maybe a bit more context here', function () {
            it('should run here few assertions', function () {
              var spy = sinon.spy();
              spy.should.be.ok;
            });
        });
    });
    
  5. Run the test with grunt: grunt test

  6. The test will fail with a described error.

Could anyone help to find out what is wrong?

4 Answers
Related