是否可以将睾丸(业力)与角度场景混合? [英] Is it possible to mix Testacular (Karma) with angular-scenario?

查看:15
本文介绍了是否可以将睾丸(业力)与角度场景混合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Testacular(现在是 Karma)很棒,角度场景也很棒.然而,将它们一起使用是一项挑战.Testacular 中有一个 ANGULAR-SCENARIO-ADAPTER,但这会破坏简单的测试.如果您自己包含 angular-scenario.js,Testacular 将根本不运行任何测试.有人能正常运行吗?

Testacular (now Karma) is awesome, so is angular-scenario. Using them together is proving a challenge however. There is an ANGULAR-SCENARIO-ADAPTER in Testacular, but that breaks simple tests. If you include angular-scenario.js yourself Testacular will run no tests at all. Has anyone got this running properly?

我尝试将它用于一个简单的测试,但我看到了一些奇怪的行为:

I've tried to use this with a trivial test, but I saw some weird behavior:

测试:

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 适配器配置时:

When adding the ANGULAR adapter config:

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 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,
   JASMINE_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 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)

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

If I add angular-scenario in the mix:

//inside testacular.conf.js
files = [
  JASMINE,
  JASMINE_ADAPTER,
  'tests/lib/angular/angular.js',
  '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)

有人让它正常运行吗?true 变成 undefined 是怎么回事?

Has anyone got this running properly? What's with the true becoming undefined?

推荐答案

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

You can't mix the 2 in one testacular configuration. What you should do is to prepare 2 distinct testacular configurations: one for running unit tests and another one for running e2e tests.

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

Then, you would run testacular twice: firstly to execute unit tests and then e2e tests. Usually I'm running unit tests very, very frequently (on each save!) while e2e tests just before a commmit (since those test run longer). We want to have the fastest possible feedback from unit tests while e2e tests are providing the ultimate safety net and assuring that parts of applications hard to cover with unit tests (navigation, UI etc.) are still working correctly.

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

This is the technique that AngularJS seed is using, you can see the corresponding definitions here: https://github.com/angular/angular-seed/tree/master/config

这篇关于是否可以将睾丸(业力)与角度场景混合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆