Testacular(现在是 Karma)很棒,角度场景也很棒。然而,将它们一起使用是一项挑战。Testacular 中有一个 ANGULAR-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 并希望 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)
如果我在混合中添加角度场景:
//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
?