NG6-starter icon indicating copy to clipboard operation
NG6-starter copied to clipboard

Unit Testing Restangular - Unknown provider: RestangularProvider <- Restangular

Open josoroma-zz opened this issue 9 years ago • 1 comments

Hi!

I was wondering if you have ideas or examples on how to apply unit testing with Restangular:

  • https://github.com/chaijs/chai-http
  • https://www.sitepoint.com/unit-test-javascript-mocha-chai
  • https://github.com/mgonto/restangular/blob/master/test/restangularSpec.js
  • https://www.uvd.co.uk/blog/bdd-angular-podcast-application-tutorial-part-2-user-searches-for-a-podcast/
FAILED TESTS:
  Home
    ✖ "before each" hook: workFn for "default component should be home"
      Chrome 53.0.2785 (Mac OS X 10.11.6)
    Error: [$injector:unpr] Unknown provider: RestangularProvider <- Restangular
    http://errors.angularjs.org/1.5.8/$injector/unpr?p0=RestangularProvider%20%3C-%20Restangular

Thanks in advance.

josoroma-zz avatar Oct 10 '16 05:10 josoroma-zz

Can you add your code as example? You only should need to import the module and then load it on beforeEach:

import ThirdPartyModule from 'angular-thirdparty';
import TestModule from './test';

describe('Some test', () => {
 // Modules import
  beforeEach(()=>{
    window.module(ThirdPartyModule );
    window.module(TestModule);
  });
});

I'm having troubles with ng-annotate and ES6 Classes though, I have to declare the controller/service as an array of dependencies and finally a function instead of a Class with ng-annotate.

thematho avatar Apr 21 '17 04:04 thematho