I am writing unit tests for my angularJS 1.4.x app Services and Controllers, the problem is all our controllers and services are declared insides modules like shown below, i.e "MyApp"
module MyApp {
'user strict';
export class MyService {
public static $inject = [
'$http',
'$rootScope',
'library'
];
constructor(private $rootScope:any,
private $http:ng.IHttpService,
private library:lib.Library) {}
// some methods...
}
}
but when i try to require this file in my test.js file it gives the following error
SyntaxError: Unexpected token, expected ";" (1:7)
here is my test file
require('../../../node_modules/angular/angular.min.js');
require('../../../node_modules/angular-mocks/angular-mocks.js');
require('../ts/MyService.ts');
describe('myService testing', function(){
beforeEach(
angular.mock.module('app')
);
var ser;
beforeEach(inject(function(myService) {
ser = myService;
}));
it('1 + 1 should equal 2', function(){
var actual = ser.addTwoNumbers(1,1);
expect(actual).toEqual(2);
});
});
requiretoimport