问题描述
Testacular(现噶)是真棒,所以角场景。使用在一起不过是证明一个挑战。有一个角情景适配器Testacular,但打破了简单的测试。如果包括角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');
});
});
与配置正常行为:
Normal behavior with 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 KRwEUtKtiaJs3MoiEsNg
Chrome 25.0: Executed 1 of 1 SUCCESS (0.061 secs / 0.003 secs)
在添加角适配器配置:
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)
添加角scenario.js并希望JASMINE适配器可以处理它。
我也试过,包括角scenario.js
我自己,但是这是一个死胡同。
Adding angular-scenario.js and hoping JASMINE-ADAPTER can handle it.
I've also tried to include angular-scenario.js
myself, but that's a dead end.
//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)
如果我在混加角方案:
//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)
有没有人有这个运行正常吗?什么是与真正
成为未定义
?
推荐答案
您不能混在2中的一个testacular配置即可。你应该做的是为 prepare 2个不同的testacular配置:一个用于运行单元测试,另一个用于运行端到端测试
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两次:首先,执行单元测试,然后端到端测试。通常我运行单元测试非常,非常频繁(在每次保存!),而端到端的测试只是一个commmit之前(因为这些试运行更长的时间)。我们希望有从单元测试的最快的反馈,而端到端的测试提供最终的安全网,并确保该应用程序坚硬的部分与单元测试(导航,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
这篇关于是否有可能与棱角分明的场景混合Testacular(噶)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!