現在、AngularJS アプリを Jasmine でテストしており、仕様に合格しています。Karma でテストを実行しようとしましたが、失敗しました。Karma は Jasmine 仕様で定義されている $scope を認識できないようですが、Jasmine ランナーは問題なく認識しています。
私のkarma.conf.js:
frameworks = ['jasmine'];
colors = true;
singleRun = true;
files = [
JASMINE,
JASMINE_ADAPTER,
ANGULAR_SCENARIO,
ANGULAR_SCENARIO_ADAPTER,
'lib/jquery-1.9.1.min.js',
'lib/angular.min.js',
'lib/angular-mocks.js',
'lib/jquery.scrollTo.js',
'lib/jquery-ui.min.js',
'lib/calendar.js',
'lib/date.js',
'src/app.js',
'spec/*.spec.js'
];
browsers = [
'PhantomJS',
'Firefox'
];
私のtest.spec.js:
describe('Application startup', function(){
beforeEach(module('app'));
describe('MainCtrl', function(){
var scope, ctrl;
beforeEach(inject(function($rootScope, $controller){
scope = $rootScope.$new();
ctrl = $controller('MainCtrl', {
$scope: scope
});
}));
it("should initialize $scope.testLoad to 42", function(){
expect(scope.testLoad).toBe(42);
});
});
});
私が得ている出力:
expect undefined toBe 42
Jasmine はこれを問題なく通過しているため、明らかに Karma または私の構成ファイルのいずれかです。どうしたの?