AngularJS - Karma(e2e):执行0 of 0 ERROR

时间:2022-11-05 14:49:19

I am experiencing a problem which I could not solve for some time, and getting very frustrating since I don't have an idea what I am doing wrong in it. :) Any help is much appreciated. I am using requirejs in my applications as well. This is basically what I am trying to build; https://github.com/Cengizism/base

我遇到了一个问题,我有一段时间无法解决这个问题,而且因为我不知道自己做错了什么而感到非常沮丧。 :) 任何帮助深表感谢。我也在我的应用程序中使用requirejs。这基本上就是我想要建立的; https://github.com/Cengizism/base

When I try to start my e2e test I get this on my console;

当我尝试开始我的e2e测试时,我在控制台上得到了这个;

INFO [karma]: Karma v0.10.0 server started at http://localhost:8080/_karma_/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 28.0.1500 (Mac OS X 10.8.4)]: Connected on socket id n-0AVRliCogs2nWBfgDz
Chrome 28.0.1500 (Mac OS X 10.8.4): Executed 0 of 0 ERROR (0.208 secs / 0 secs)

My configuration file looks like this;

我的配置文件如下所示;

module.exports = function(karma) {
    'use strict';

    karma.set({
        frameworks: ['jasmine', 'ng-scenario'],

        files: [
          'app/vendors/angular-scenario/angular-scenario.js',
          'test/e2e/*.js'
        ],

        basePath: '',

        exclude: [],

        reporters: ['progress'],

        port: 8080,

        runnerPort: 9100,

        colors: true,

        logLevel: karma.LOG_INFO,

        autoWatch: true,

        browsers: ['Chrome'],

        captureTimeout: 5000,

        singleRun: false,

        proxies: {
          '/': 'http://localhost:9000/'
        },

        urlRoot: '/_karma_/',

        plugins: [
          'karma-jasmine',
          'karma-ng-scenario',
          'karma-chrome-launcher',
          'karma-firefox-launcher',
          'karma-phantomjs-launcher'
        ]
    });
};

and finally the spec file;

最后是spec文件;

describe('Simple E2e Test', function()
{
    it('Should open the front page and check', function()
    {
        browser().navigateTo('/#/partial1');

        sleep(1);

        expect(element('#test').html()).toEqual('Hi testUser1');
    });
});

5 个解决方案

#1


12  

Maybe this could help you:

也许这可以帮助你:

To fix it, the following line should be included in karma.conf.js

要修复它,karma.conf.js中应包含以下行

exclude: ['app/lib/angular/angular-scenario.js'],

Source : https://github.com/angular/angular-phonecat/issues/71

资料来源:https://github.com/angular/angular-phonecat/issues/71

#2


4  

I'm not exactly clear on this either, but after running into this issue I removed the file angular-scenario from loading and was able to get the tests to run. I believe the problem is the difference between unit testing and e2e testing configuration.

我对此也不是很清楚,但在遇到这个问题后,我从加载中删除了文件角度场景,并且能够运行测试。我认为问题在于单元测试和e2e测试配置之间的区别。

#3


3  

I had this same error, and it went away once I started adding some tests. Is it possible the error just means there aren't any tests present?

我有同样的错误,一旦我开始添加一些测试它就消失了。错误是否可能意味着没有任何测试?

#4


0  

It could be due to the relative paths you add in files [] which may be wrong. I had the same error, and after it works fine !

这可能是由于您在files []中添加的相对路径可能是错误的。我有同样的错误,并在它工作正常后!

#5


0  

In my case, the module format was wrong in a shim file that was only used by karma. I changed the format to 'register' to support SystemJS modules, per the documentation found here.

就我而言,模块格式在仅由karma使用的shim文件中是错误的。根据此处的文档,我将格式更改为“register”以支持SystemJS模块。

System.config({
    packages: {
        'base/dist/client': {
            warnings: true,
            defaultExtension: 'js',
            format: 'register',
            map: { }
        }
    }
});

This is what the TS output looked like. I have to assume that these tests were wrapped as system modules, so they were not loading properly. In other words, the error resulted from no tests running.

这就是TS输出的样子。我必须假设这些测试被包装为系统模块,因此它们没有正确加载。换句话说,错误是由于没有运行测试而导致的。

System.register(['angular2/testing', "./data-pipe"], function(exports_1) {
    var testing_1, data_pipe_1;
    return {
        setters:[
            function (testing_1_1) {
                testing_1 = testing_1_1;
            }
        ]

              // yada, yada, yada..

        }
    }
});

#1


12  

Maybe this could help you:

也许这可以帮助你:

To fix it, the following line should be included in karma.conf.js

要修复它,karma.conf.js中应包含以下行

exclude: ['app/lib/angular/angular-scenario.js'],

Source : https://github.com/angular/angular-phonecat/issues/71

资料来源:https://github.com/angular/angular-phonecat/issues/71

#2


4  

I'm not exactly clear on this either, but after running into this issue I removed the file angular-scenario from loading and was able to get the tests to run. I believe the problem is the difference between unit testing and e2e testing configuration.

我对此也不是很清楚,但在遇到这个问题后,我从加载中删除了文件角度场景,并且能够运行测试。我认为问题在于单元测试和e2e测试配置之间的区别。

#3


3  

I had this same error, and it went away once I started adding some tests. Is it possible the error just means there aren't any tests present?

我有同样的错误,一旦我开始添加一些测试它就消失了。错误是否可能意味着没有任何测试?

#4


0  

It could be due to the relative paths you add in files [] which may be wrong. I had the same error, and after it works fine !

这可能是由于您在files []中添加的相对路径可能是错误的。我有同样的错误,并在它工作正常后!

#5


0  

In my case, the module format was wrong in a shim file that was only used by karma. I changed the format to 'register' to support SystemJS modules, per the documentation found here.

就我而言,模块格式在仅由karma使用的shim文件中是错误的。根据此处的文档,我将格式更改为“register”以支持SystemJS模块。

System.config({
    packages: {
        'base/dist/client': {
            warnings: true,
            defaultExtension: 'js',
            format: 'register',
            map: { }
        }
    }
});

This is what the TS output looked like. I have to assume that these tests were wrapped as system modules, so they were not loading properly. In other words, the error resulted from no tests running.

这就是TS输出的样子。我必须假设这些测试被包装为系统模块,因此它们没有正确加载。换句话说,错误是由于没有运行测试而导致的。

System.register(['angular2/testing', "./data-pipe"], function(exports_1) {
    var testing_1, data_pipe_1;
    return {
        setters:[
            function (testing_1_1) {
                testing_1 = testing_1_1;
            }
        ]

              // yada, yada, yada..

        }
    }
});