2

我尝试使用 Grunt Karma 运行 E2E 测试,但没有成功。我看了很多解决方案,但没有一个有效!

我的业力-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");”行

任何想法?

4

2 回答 2

0

确保你运行你的网络服务器也是业力。尝试将您的代理设置更改为以下内容:

    proxies: {
    '/': 'http://localhost:8000/'
    },
于 2013-09-07T03:01:13.893 回答
0

你需要

 plugins: [
      'karma-ng-scenario',
    ],

在你的配置文件中。

先做 npm install karma-ng-scenario --save-dev _

于 2013-10-09T22:50:39.333 回答