【问题标题】:can't run e2e tests with karma (for angular)无法使用 karma 运行 e2e 测试(对于角度)
【发布时间】:2013-07-01 15:24:01
【问题描述】:

我可以运行单元测试和中间测试,但是当我想运行 e2e 测试时,什么都没有发生。业力的输出表明没有找到测试:

C:\>karma start
INFO [karma]: Karma server started at http://localhost:9876/
INFO [launcher]: Starting browser IE
INFO [IE 10.0 (Windows)]: Connected on socket id 8lG9jAG8mloBmjFez5V9
IE 10.0 (Windows): Executed 0 of 0 SUCCESS (0.125 secs / 0 secs)

我的 karma.conf 文件如下:

files = [
 JASMINE,
 JASMINE_ADAPTER,
 'Scripts/libs/jquery/jquery-*.js',
 'Scripts/libs/angular/angular.js',
 'Scripts/libs/angular/angular-mocks.js',
 'Scripts/libs/angular/angular-resource.js',
 'Scripts/libs/angular/angular-scenario.js',
 'Scripts/sinon-1.7.3.js',
 'app/**/index.js', 
 'app/**/*.js',
 'app/*.js',
 'test/unit/**/*.js',
 'test/midway/**/*.js',
 'test/e2e/*.js'
];


reporters = ['progress'];
port = 9876;
runnerPort = 9100;
colors = true;
logLevel = LOG_INFO;
autoWatch = true;
browsers = ['IE'];
captureTimeout = 60000;
singleRun = false;
proxies = {
   '/': 'http://localhost:1506/portal.web'
};

知道有什么问题吗?

【问题讨论】:

  • 您是否尝试过让您的 e2e 测试与这样的测试运行器一起工作:github.com/angular/angular-seed/blob/master/test/e2e/…
  • 我要放弃了。我找不到关于如何为 e2e 测试设置业力的好教程。当我按照 Angular 网站 (docs.angularjs.org/tutorial/step_03) 上的教程进行操作时,假设太多,根本没有帮助。浏览到localhost:8000/test/e2e/runner.html 会失败,尽管我已经在 karma.conf 文件的 proxies 参数中指定了这个端口。正如你告诉我的那样,我已经添加了测试运行器 html 文件,没有任何效果....
  • 测试运行者不使用业力。只需从与您的应用程序相同的 Web 服务器在您的浏览器中打开它

标签: testing angularjs karma-runner angularjs-e2e


【解决方案1】:

我遇到了同样的问题 - 几乎放弃了 - 但关注了 http://blog.diniscruz.com/2013/06/running-karmas-angularjs-example.html - 它有效!

【讨论】:

  • 感谢您链接到该博客文章,很高兴它对您有所帮助。如果你还在看 Karma,我刚刚发布了一篇后续文章,展示了我如何创建一组 Eclipse 视图来帮助运行我的测试:blog.diniscruz.com/2014/02/…
【解决方案2】:

AngularJS 团队建议 Protractor 用于 E2E 测试,而 Karma 仅用于单元测试。

【讨论】:

    【解决方案3】:

    setting up karma for e2e testing

    您还需要在 karma.conf.js 中的文件中注释掉 JASMINE 和 JASMINE_ADAPTER 并在其下方添加 frameworks = "jasmine"。 希望这会有所帮助

    【讨论】:

      【解决方案4】:
          // frameworks to use
                      frameworks: ['jasmine']
      

      通过在配置文件中添加上面的这些行对我有用。

      根据 [https://github.com/ksunair/introtokarma][1]

      【讨论】:

        【解决方案5】:
        frameworks: ['jasmine'],
        
        files: [
            //adapter - ignore deprecation warnings karma spits out -- you need this!
            //JASMINE, 
            //JASMINE_ADAPTER,
            ANGULAR_SCENARIO,
            ANGULAR_SCENARIO_ADAPTER,
        
            //includes
            'client/common/vendor/angular.js',
        
            //own files
            'client/admin/views/admin.html',
        
            //tests
            //'test/client/*-unit-spec.js',
            'test/client/*-e2e-spec.js'
        ]
        

        (对于ANGULAR_SCENARIO,您将完成npm install karma-ng-scenario --save-dev

        Jasmine 不是 E2E,E2E(虽然看起来很相似)不是 Jasmine。您需要包括其中一个或另一个,而不是两者。

        请参阅this answer 了解更多信息。

        FWIW,我的版本:

        • 业力:0.10.8
        • 因果报应场景:0.1.0
        • 业力茉莉花:0.1.5

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2019-05-01
          • 2015-03-23
          • 1970-01-01
          • 2016-10-13
          • 2020-12-07
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多