我尝试使用Grunt Karma运行E2E测试,但没有成功。我已经寻找了很多解决方案,但都没有成功!
我的karma-e2e.conf.js:
module.exports = function(config) {
config.set({
// base path, that will be used to resolve files and exclude
basePath: '../',
// frameworks to use
frameworks: ['ng-scenario'],
// list of files / patterns to load in the browser
files: [
'test/e2e/**/*.js',
'test/e2e/*.js'
],
// list of files to exclude
exclude: [
],
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress'],
// web server port
port: 9877,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level 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: true,
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['PhantomJS'],
// If browser does not capture in given timeout [ms], kill it
captureTimeout: 60000,
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: true,
// Uncomment the following lines if you are using grunt's server to run the tests
proxies: {
'/': 'http://localhost/test/e2e/'
},
// URL root prevent conflicts with the site root
urlRoot: '/_karma_/'
});};
PS:我的应用程序运行在80端口(Apache默认端口)。
我的规格如下:
describe('E2E: Testing Routes:', function () {
'use strict';
beforeEach(function() {
browser().navigateTo('/');
});
it('should jump to the /videos path when / is accessed', function() {
browser().navigateTo('#/');
expect(browser().location().path()).toBe("/main");
});})
所以,当我运行这个规范时,我收到了这样的消息:
“类型错误:未定义的不是函数(计算$document.injector())”
此错误发生在"expect(browser().location().path()).toBe("/main");“行
有什么想法吗?
发布于 2013-09-07 11:01:14
确保你正在运行你的web服务器,同时也是因果报应。尝试将您的代理设置更改为如下所示:
proxies: {
'/': 'http://localhost:8000/'
},发布于 2013-10-10 06:50:39
你需要
plugins: [
'karma-ng-scenario',
],在您的配置文件中。
先做npm install karma-ng-scenario --save-dev
https://stackoverflow.com/questions/18603480
复制相似问题