我最终决定从 testacular (0.4.0) 迁移到 karma 0.8.5。我的测试是用 CoffeeScript 编写的 Jasmine。
这是输出karma start path/to/karma.conf.js
:
INFO [karma]: Karma server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 26.0 (Mac)]: Connected on socket id MOOnxLR89NKLGrrzbTI_
Chrome 26.0 (Mac) ERROR
Uncaught SyntaxError: Unexpected string
at /Users/genghis/Projects/chirper/client/test/spec/authenticationSpec.coffee:1
Chrome 26.0 (Mac): Executed 0 of 0 ERROR (1.246 secs / 0 secs)
查看调试器控制台,每个测试文件都有类似的错误。我已经配置了预处理器,但似乎没有编译咖啡脚本?这是我的karma.conf.js
:
basePath = '';
files = [
JASMINE,
JASMINE_ADAPTER,
'../app/components/angular/angular.js',
'../app/components/angular-mocks/angular-mocks.js',
'../app/scripts/*.js',
'../app/scripts/**/*.js',
'../app/components/socket.io-client/dist/socket.io.js',
'../test/spec/**/*.coffee'
];
exclude = [];
reporter = 'progress';
port = 9876;
runnerPort = 9100;
colors = true;
logLevel = LOG_INFO;
autoWatch = true;
browsers = ['Chrome'];
singleRun = false;
preprocessors = {
'**/*.coffee': 'coffee'
};
有任何想法吗?提前致谢!
更新:
我可以通过使用节点 cli 运行 CS 测试文件来重现错误。所以很明显咖啡脚本没有被编译。文件的第一行(失败)如下所示:
describe 'Authentication', ->