PatrickJS / NG6-starter

:ng: An AngularJS Starter repo for AngularJS + ES6 + Webpack
https://angularclass.github.io/NG6-starter
Apache License 2.0
1.91k stars 1.35k forks source link

Unit Testing Restangular - Unknown provider: RestangularProvider <- Restangular #177

Open josoroma-zz opened 7 years ago

josoroma-zz commented 7 years ago

Hi!

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

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.

thematho commented 7 years ago

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.