I am currently developing tests for an angular app that consists of a mix of ES5 and ES6 files. To transpile the ES6 files, I am using babel CLI with the options --modules system --module-ids. Here is an example of what I have:
ES5 file:
angular.module('app').controller('A', function($scope) {
...
});
ES6 file:
export class B {
constructor($scope) {
this.$scope = $scope
}
...
}
Additionally, I have a file called boot.js:
import {B} from 'controllers/B';
angular.module('app').controller('B', B);
On my page, I import the boot file using es6-module-loader and bootstrap the angular app:
System.import('boot').then(function() {
angular.bootstrap(document, ['app']);
});
Now, I believe that I need to handle loading boot.js before running my tests in karma. Currently, I am doing this by calling System.import('boot') in my test files, but it doesn't seem like the most efficient approach:
'use strict';
System.import('boot');
describe('Controller: B', function() {
beforeEach(module('app'));
var $scope;
beforeEach(inject(function(_$rootScope_, $controller) {
scope = _$rootScope_.$new();
$controller('B', {$scope: $scope});
}));
it('...', function() {
});
});
Is there a better way to handle this situation?