//Service Spec code :
define([], function () {
'use strict';
describe('search Service spec', function () {
var searchService;
beforeEach(angular.module('flightRouteApp', []));
describe('service methods', function () {
it('should calculate the length of the element', inject(function (searchService) {
expect(searchService).toBeDefined();
}));
});
});
});
// Karma configuration
// Generated on Sun Mar 05 2017 09:17:46 GMT+0100 (W. Europe Standard Time)
/* global module */
"use strict";
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine','requirejs'],
// list of files / patterns to load in the browser
files: [
{pattern:'node_modules/angular/angular.js',watched: true, included: true, served: true},
{pattern:'node_modules/angular-mocks/angular-mocks.js',watched: true, included: true, served: true},
{pattern:'app/js/flightRoute.js',watched: true, included: true, served: true},
{pattern:'app/js/services/*.js',watched: true, included: true, served: true},
{pattern:'app/js/**/*.js',watched: true, included: true, served: true},
{pattern:'tests/test-main.js',watched: true, included: true, served: true},
{pattern: 'tests/**/*.Spec.js',watched: true, included: true, served: true}
],
// list of files to exclude
exclude: [ ],
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
/*reporters: ['progress','coverage'],*/
reporters: config.angularCli && config.angularCli.codeCoverage
? ['progress', 'coverage-istanbul']
: ['progress', 'kjhtml'],
preprocessors: {
'app/js/**/*.js': 'coverage'
},
// web server port
port: 9876,
coverageReporter: {includeAllSources: true, reporters:[{type: 'html', dir:'coverage/'}]},
// enable / disable colors in the output (reporters and logs)
colors: true,
//vel of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR ||
config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['Chrome'],
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false,
// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity
})
}
答案 0 :(得分:0)
只需更改您的beforeEach,即可:
beforeEach(module('flightRouteApp'));