首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AngularJS + Grunt + Karma + E2E

AngularJS + Grunt + Karma + E2E
EN

Stack Overflow用户
提问于 2013-09-04 08:18:45
回答 2查看 3.7K关注 0票数 2

我尝试使用Grunt Karma运行E2E测试,但没有成功。我已经寻找了很多解决方案,但都没有成功!

我的karma-e2e.conf.js:

代码语言:javascript
复制
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默认端口)。

我的规格如下:

代码语言:javascript
复制
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");“行

有什么想法吗?

EN

回答 2

Stack Overflow用户

发布于 2013-09-07 11:01:14

确保你正在运行你的web服务器,同时也是因果报应。尝试将您的代理设置更改为如下所示:

代码语言:javascript
复制
    proxies: {
    '/': 'http://localhost:8000/'
    },
票数 0
EN

Stack Overflow用户

发布于 2013-10-10 06:50:39

你需要

代码语言:javascript
复制
 plugins: [
      'karma-ng-scenario',
    ],

在您的配置文件中。

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18603480

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档