热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

与Karma的角度E2E:不可靠的事件处理-AngularE2EwithKarma:unreliableeventhandling

ImconfrontedwithastrangeerrorwhenexecutingmyE2Etests.Abroadcastedeventisnotconsumed

I'm confronted with a strange error when executing my E2E tests. A broadcasted event is not consumed by one of my directives anymore and therefore a particular view is not rendered correctly.

执行我的E2E测试时,我遇到了一个奇怪的错误。我的某个指令不再使用广播事件,因此无法正确呈现特定视图。

This does not occur only when I run the test alone. And, this does not occur either when I run the test for the first time (singleRun=true) or the first run in debug mode.

仅当我单独运行测试时才会发生这种情况。并且,当我第一次运行测试(singleRun = true)或第一次运行调试模式时,这不会发生。

The implemented event logic itself works fine.

实现的事件逻辑本身工作正常。

What can cause this strange behavior?

什么可以导致这种奇怪的行为?

My set up:

我的设置:

  • Karma version: 0.10.10
  • Karma版本:0.10.10

  • Angular version: 1.3.0
  • 角度版本:1.3.0

My Karma Config:

我的Karma配置:

module.exports = function(config) {
config.set({

    basePath: '',

    files: [
        'test/e2e/*.js'
    ],

    singleRun: true,

    frameworks: ['ng-scenario', 'jasmine-jquery', 'jasmine'],

    browsers: ['Chrome'],

    plugins: [
        'karma-chrome-launcher',
        'karma-jasmine-jquery',
        'karma-jasmine',
        'karma-junit-reporter',
        'karma-ng-scenario'
    ],

    junitReporter: {
        outputFile: 'test-result.xml'
    },
    urlRoot: '/_karma_/',
    proxies: {
        '/': 'http://localhost:' + (process.env.PORT ? process.env.PORT : '8080') + "/"
    },
});
};

Any hints are very much appreciated!

任何提示都非常感谢!

Thanks, Sebastian

1 个解决方案

#1


As Thomas pointed out: Protractor is more appropriate for angular acceptance/E2E tests (https://docs.angularjs.org/guide/e2e-testing).

托马斯指出:量角器更适合角度接受/ E2E测试(https://docs.angularjs.org/guide/e2e-testing)。

When using Protractor as test runner, the issue does not occur (at least not, when executing it only once [which was working fine with karma as well g]).

当使用Protractor作为测试运行器时,问题不会发生(至少不会发生,只执行一次[因为karma也正常工作])。

Thanks anyhow.


推荐阅读
author-avatar
小破孩子520
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有