wardbell / bardjs

Spec helpers for testing angular v.1.x apps with Mocha, Jasmine and QUnit
MIT License
178 stars 34 forks source link

PhantomJS error, works well in Chrome and Firefox #2

Closed lodnert closed 9 years ago

lodnert commented 9 years ago

Hi!

I was just trying out bardjs and it seams to work fine in Chrome and Firefox, but when i run it in PhantomJS i get this error:

PhantomJS 1.9.8 (Mac OS X) Template Controller "before each" hook FAILED
    TypeError: 'undefined' is not a function (evaluating 'getCtxFromArgs.bind(this)')
        at bardInject (/Users/lodnert/projects/myapp/app/bower_components/bardjs/dist/bard.js:277)
        at /Users/lodnert/projects/myapp/test/spec/app/registry/template.controller.js:8
PhantomJS 1.9.8 (Mac OS X): Executed 1 of 1 (1 FAILED) ERROR (0.002 secs / 0 secs)

Here is the spec-file.


describe('Controller: Auth', function () {
  var controller;
  beforeEach(function() {

      bard.appModule('myapp.auth');
      bard.inject('$controller', '$rootScope');

  });

  it('should be created successfully', function () {
    expect('hello').toBeDefined();
  });

});

Any ideas?

rodleviton commented 9 years ago

I am getting a similar error. I am also using phantomJS:

beforeEach(function() {
        bard.appModule('myModule');
        bard.inject(this, '$controller', '$log', '$q', '$rootScope');
    });

TypeError: 'undefined' is not a function (evaluating 'getCtxFromArgs.bind(this)') at bardInject (/bower_components/bardjs/dist/bard.js:273)

Any help would be really appreciated.

rodleviton commented 9 years ago

@lodnert I have just found the solution. Phantom JS does not support Function.prototype.bind so you will need a polyfill. @wardbell has made this available here

lodnert commented 9 years ago

Ah, awesome. I will try it out later today. Thanks!

wardbell commented 9 years ago

I think I should just fold this into bard so that no one encounters it again.

That's why I am reopening this issue.

lodnert commented 9 years ago

Sounds great, I was actually coming back here to suggest something like that.

wardbell commented 9 years ago

Done. See bardjs v.0.1.1