遗言(现在的业力)很棒,角度场景也是如此。然而,将它们一起使用是一个挑战。在睾丸中有一个ANGENLAR-SCENARIO- ADAPTER,但这打破了简单的测试。如果您自己包含angular-scenario.js,Testacular将完全不进行任何测试。有人能正常运行吗?
我已经尝试过使用它进行琐碎的测试,但是我看到了一些奇怪的行为:
测试:
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, 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自己,但这是一个死胡同。
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)
如果我在混合中添加角度场景:
//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?
true
undefined
您不能将2种混合在一种睾丸的结构中 。您应该做的是 准备两种不同的睾丸配置 :一种用于运行单元测试,另一种用于运行e2e测试。
然后,您将 运行两次testacular :首先执行单元测试,然后执行e2e测试。通常我会非常非常频繁地运行单元测试(每次保存!),而在提交之前进行e2e测试(因为这些测试运行时间更长)。我们希望从单元测试中获得尽可能最快的反馈,同时e2e测试提供最终的安全网,并确保应用程序难以覆盖的部分应用程序(导航,UI等)仍能正常工作。
这是AngularJS种子使用的技术,您可以在此处查看相应的定义:https : //github.com/angular/angular- seed/tree/master/config