anglejs – 是否可以将“克拉玛”(Karma)与角度场景混合?

前端之家收集整理的这篇文章主要介绍了anglejs – 是否可以将“克拉玛”(Karma)与角度场景混合?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Testacular(现在的Karma)很棒,角度场景也是如此.将它们合在一起证明是一个挑战.在Testacular中有一个ANGULAR-SCENARIO-ADAPTER,但是这样就可以打破简单的测试.如果你自己包括angular-scenario.js,Testacular将不会执行任何测试.有没有人正确运行这个?

角情景ADAPTER

我试图用这个微不足道的测试,但是我看到一些奇怪的行为:

测试:

describe('Simple',function(){
    it('should compare strings',function(){
        expect('foo').toBe('foo');
    });
});

配置正常行为:

files = [
  JASMINE,JASMINE_ADAPTER,//    ANGULAR_SCENARIO,//    ANGULAR_SCENARIO_ADAPTER,'tests/lib/angular/angular.js','tests/sample.js'
];

输出

$testacular start
info: Testacular server started at http://localhost:9876/
info (launcher): Starting browser ChromeCanary
info (Chrome 25.0): Connected on socket id KRwEUtKtiaJs3MoiEsNg
Chrome 25.0: Executed 1 of 1 SUCCESS (0.061 secs / 0.003 secs)

添加ANGULAR适配器配置:

files = [
  JASMINE,ANGULAR_SCENARIO,ANGULAR_SCENARIO_ADAPTER,'tests/sample.js'
];

输出是:

$testacular start
info: Testacular server started at http://localhost:9876/
info (launcher): Starting browser ChromeCanary
info (Chrome 25.0): Connected on socket id 5YZA2fSuNXjmI-yRFGF6
Chrome 25.0 Simple should compare strings Failed
        expect undefined toBe "foo"
        /Users/iwein/projects/epec/spa/tests/sample.js:3:9: expected "foo" but was undefined
Chrome 25.0: Executed 1 of 1 (1 Failed) (0.195 secs / 0.018 secs)

添加angular-scenario.js并希望JASMINE-ADAPTER可以处理它.

我也试图自己包括angular-scenario.js,但这是一个死胡同.

//inside testacular.conf.js
files = [
   JASMINE,'tests/sample.js'
];

我得到输出

$testacular start
info: Testacular server started at http://localhost:9876/
info (launcher): Starting browser ChromeCanary
info (Chrome 24.0): Connected on socket id uEzVQ6tqSu7M7tak4F6v
Chrome 24.0 Array #indexOf() should return -1 when the value is not present Failed
    Expected true to be false.
    Error: Expected true to be false.
        at null.<anonymous> (/..../tests/sample.js:4:17)
Chrome 24.0: Executed 1 of 1 (1 Failed) (0.07 secs / 0.004 secs)

如果我在混合中添加角度场景:

//inside testacular.conf.js
files = [
  JASMINE,'tests/lib/angular/angular-scenario.js','tests/sample.js'
];

测试根本不运行:

$testacular start
 info: Testacular server started at http://localhost:9876/
 info (launcher): Starting browser ChromeCanary
 info (Chrome 24.0): Connected on socket id GcyCTxuvhyFcCaE14BEP
 Chrome 24.0: Executed 0 of 0 SUCCESS (0.116 secs / 0 secs)

有没有人正确运行这个?真正的变化是什么?

您不能在一个testacular配置中混合2.您应该做的是准备2个不同的testacular配置:一个用于运行单元测试,另一个用于运行e2e测试.

然后,您将执行两次testacular:首先执行单元测试,然后再进行e2e测试.通常,我正在运行单元测试,非常频繁(每次保存!),而e2e在一个委托之前进行测试(因为这些测试运行时间更长).我们希望从单元测试中获得最快的反馈,而e2e测试正在提供最终的安全网络,并确保部分应用程序难以用单元测试(导航,UI等)覆盖仍能正常工作.

这是AngularJS种子使用的技术,您可以在这里看到相应的定义:https://github.com/angular/angular-seed/tree/master/config

原文链接:/angularjs/140756.html

猜你在找的Angularjs相关文章