我一直在尝试将我们的AngularJS应用程序从1.2.6升级到1.3.5,但在尝试运行测试时一直遇到错误,并且在测试初始化时发生错误。进一步的调查证明,测试甚至没有在插入点处被击中,而是在初始化之后失败。
我们正在使用Jasmine 1.x和karma test runner与Chrome作为浏览器。我们也使用grunt按以下顺序启动测试:
grunt.registerTask('test', function () {
console.log(config);
grunt.task.run([
'jsbeautifier',
'newer:jshint',
'clean:server',
'autoprefixer',
'replace:htmlcommon',
'replace:htmlenv',
'replace:jscommon',
'replace:jsenv',
'to_single_quotes',
'connect:test',
'karma'
]);
});
以下是错误日志:
LOG: 'WARNING: Tried to load angular more than once.'
Chrome 39.0.2171 (Mac OS X 10.10.1) ERROR
Uncaught TypeError: undefined is not a function
at /Users/devUser/Development/WebAppGroup/webapp/app/bower_components/angular/angular.js:25917
Chrome 39.0.2171 (Mac OS X 10.10.1) ERROR
Uncaught TypeError: undefined is not a function
at /Users/devUser/Development/WebAppGroup/webapp/app/bower_components/angular-resource/angular-
resource.js:8
Chrome 39.0.2171 (Mac OS X 10.10.1) ERROR
Uncaught TypeError: undefined is not a function
at /Users/devUser/Development/WebAppGroup/webapp/app/bower_components/angular-sanitize/angular-
sanitize.js:8
Chrome 39.0.2171 (Mac OS X 10.10.1) ERROR
Uncaught TypeError: undefined is not a function
at /Users/devUser/Development/WebAppGroup/webapp/app/bower_components/angular-route/angular-
route.js:26
Chrome 39.0.2171 (Mac OS X 10.10.1): Executed 0 of 0 ERROR (0.391 secs / 0 secs)
依赖项的摘录形成我们的业力配置文件:
'app/scripts/common/googlemaps.js',
'app/bower_components/angular/angular.js',
'app/bower_components/angular-translate/angular-translate.js',
'app/bower_components/angular-translate-loader-partial/angular-translate-loader-partial.js',
'app/bower_components/angular-mocks/angular-mocks.js',
'app/bower_components/angular-resource/angular-resource.js',
'app/bower_components/angular-cookies/angular-cookies.js',
'app/bower_components/angular-sanitize/angular-sanitize.js',
'app/bower_components/angular-route/angular-route.js',
'app/bower_components/momentjs/moment.js',
'app/bower_components/angular-touch/angular-touch.js',
'app/bower_components/angular-carousel/dist/angular-carousel.js',
'app/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js',
'app/bower_components/angular-scroll/angular-scroll.js',
'app/bower_components/jquery/dist/jquery.min.js',
'app/bower_components/jquery/dist/jquery.js',
'app/bower_components/angularitics/src/angulartics.js',
'app/bower_components/angularitics/src/angulartics-adobe.js',
'app/bower_components/angularitics/src/angulartics-chartbeat.js',
'app/bower_components/angularitics/src/angulartics-flurry.js',
'app/bower_components/angularitics/src/angulartics-ga-cordova.js',
'app/bower_components/angularitics/src/angulartics-ga.js',
'app/bower_components/angularitics/src/angulartics-gtm.js',
'app/bower_components/angularitics/src/angulartics-kissmetrics.js',
'app/bower_components/angularitics/src/angulartics-mixpanel.js',
'app/bower_components/angularitics/src/angulartics-piwik.js',
'app/bower_components/angularitics/src/angulartics-scroll.js',
'app/bower_components/angularitics/src/angulartics-segmentio.js',
'app/bower_components/angularitics/src/angulartics-splunk.js',
'app/bower_components/angularitics/src/angulartics-woopra.js',
'app/bower_components/angularitics/src/angulartics-marketo.js',
'app/bower_components/ngstorage/ngStorage.js',
'app/bower_components/ng-clip/src/ngClip.js',
'app/bower_components/zeroclipboard/dist/ZeroClipboard.js',
更新以下是整个业力配置文件:
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
// testing framework to use (jasmine/mocha/qunit/...)
frameworks: ['jasmine', 'ng-scenario'],
// list of files / patterns to load in the browser
files: [
'app/scripts/common/googlemaps.js',
'app/bower_components/angular/angular.js',
'app/bower_components/angular-translate/angular-translate.js',
'app/bower_components/angular-translate-loader-partial/angular-translate-loader-partial.js',
'app/bower_components/angular-mocks/angular-mocks.js',
'app/bower_components/angular-resource/angular-resource.js',
'app/bower_components/angular-cookies/angular-cookies.js',
'app/bower_components/angular-sanitize/angular-sanitize.js',
'app/bower_components/angular-route/angular-route.js',
'app/bower_components/momentjs/moment.js',
'app/bower_components/angular-touch/angular-touch.js',
'app/bower_components/angular-carousel/dist/angular-carousel.js',
'app/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js',
'app/bower_components/angular-scroll/angular-scroll.js',
'app/bower_components/jquery/dist/jquery.min.js',
'app/bower_components/jquery/dist/jquery.js',
'app/bower_components/angularitics/src/angulartics.js',
'app/bower_components/angularitics/src/angulartics-adobe.js',
'app/bower_components/angularitics/src/angulartics-chartbeat.js',
'app/bower_components/angularitics/src/angulartics-flurry.js',
'app/bower_components/angularitics/src/angulartics-ga-cordova.js',
'app/bower_components/angularitics/src/angulartics-ga.js',
'app/bower_components/angularitics/src/angulartics-gtm.js',
'app/bower_components/angularitics/src/angulartics-kissmetrics.js',
'app/bower_components/angularitics/src/angulartics-mixpanel.js',
'app/bower_components/angularitics/src/angulartics-piwik.js',
'app/bower_components/angularitics/src/angulartics-scroll.js',
'app/bower_components/angularitics/src/angulartics-segmentio.js',
'app/bower_components/angularitics/src/angulartics-splunk.js',
'app/bower_components/angularitics/src/angulartics-woopra.js',
'app/bower_components/angularitics/src/angulartics-marketo.js',
'app/bower_components/ngstorage/ngStorage.js',
/* 'app/bower_components/ng-clip/src/ngClip.js',
'app/bower_components/zeroclipboard/dist/ZeroClipboard.js',*/
'app/scripts/directives/setup.js',
'app/scripts/*.js',
'app/scripts/**/*.js',
'test/mock/**/*.js',
'test/spec/**/*.js'
],
// list of files / patterns to exclude
exclude: [],
// web server port
port: 8080,
// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['Chrome'],
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false,
reporters: ['progress', 'coverage'],
preprocessors: {
'app/scripts/**/*.js': ['coverage']
}
});
};
基本上在通过bower安装所有依赖项后,bower抱怨几个依赖项不同意AngularJS 1.3.x,而是需要1.2.x,其中x =个别依赖项所需的次要版本。我已经尝试过做出多数规则'采取并给出1.2.27(其中大部分依赖关系都要求该特定版本)并且我尝试过强力1.3.5升级。
作为最后的手段,我也应用了' *'到我的bower.json文件中的依赖项,以获取与AngularJS 1.3.5一起使用的每个依赖项的最新版本,但这并不起作用。
功能集的工作原理我可以启动我的角度应用程序并完成大部分功能,但是当涉及到你的BDD测试时,这会失败。
我已经陷入困境,因为我已尝试过所有可能的路径。我认为这个问题与我们正在使用的大量库以及它对旧版AngularJS的个别要求有关。另外,为什么尝试多次加载AngularJS?由于路线不好或缺失,我已经读到了这种可能性,但是当应用程序启动时我们的路线运行良好。
有什么想法吗?
谢谢, 本。