angular-fullstack / generator-angular-fullstack

Yeoman generator for an Angular app with an Express server
https://awk34.gitbook.io/generator-angular-fullstack
6.12k stars 1.24k forks source link

problem on file.controller.spec.js when running "grunt test:client" for a new route #2029

Closed Emidomenge closed 8 years ago

Emidomenge commented 8 years ago

If I run : yo angular-fullstack:route example

And then run grunt test:client --force

I got this error just after example.controller.spec.js has been created : (I'm beginner with Jasmine)

jasmine_error_1

File example.controller.spec.js looks like this :

'use strict';

describe('Component: ExampleComponent', function () {

  // load the controller's module
  beforeEach(module('myModule'));

  var ExampleComponent, scope;

  // Initialize the controller and a mock scope
  beforeEach(inject(function ($componentController, $rootScope) {
    scope = $rootScope.$new();
    ExampleComponent = $componentController('ExampleComponent', {
      $scope: scope
    });
  }));

  it('should ...', function () {
    expect(1).toEqual(1);
  });
});

And file example.controller.js looks like this :

'use strict';
(function(){

class ExampleComponent {
  constructor() {
    this.message = 'Hello';
  }
}

angular.module('myModule')
  .component('example', {
    templateUrl: 'app/example/example.html',
    controller: ExampleComponent
  });

})();
Item Version
generator-angular-fullstack 3.7.4
Node 5.7.1
npm 3.6.0
Operating System Windows 7
Item Answer
Transpiler Babel
Markup HTML
CSS CSS
Router ngRoute
Build Tool Grunt
Client Tests Jasmine
DB MongoDB
Auth Y
Emidomenge commented 8 years ago

It works if example.controller.spec.js looks like this :

changing "ExampleComponent" by "example"

'use strict';

describe('Component: ExampleComponent', function () {

  // load the controller's module
  beforeEach(module('myModule'));

  var ExampleComponent, scope;

  // Initialize the controller and a mock scope
  beforeEach(inject(function ($componentController, $rootScope) {
    scope = $rootScope.$new();
    ExampleComponent = $componentController('example', { // <------------------ HERE
      $scope: scope
    });
  }));

  it('should ...', function () {
    expect(1).toEqual(1);
  });
});
Awk34 commented 8 years ago

This has been fixed with https://github.com/DaftMonk/generator-ng-component/commit/72ad578ab6b4d49e32acf61ef017cd36d42efcdb. I just need to make another release.

Awk34 commented 8 years ago

Closed with https://github.com/angular-fullstack/generator-angular-fullstack/commit/80957817cb4ccaebe41bcf12aa691098ce2f53e0; wait for next release of generator.