6
首先,我使用Yeoman发生器角度发生器搭建了一个角度项目。测试失败,出现新的发生器角度项目(CoffeeScript)
$ mkdir project && cd project
$ yo angular --coffee
...
[?] Would you like to use Sass (with Compass)? Yes
[?] Would you like to include Twitter Bootstrap? Yes
[?] Would you like to use the Sass version of Twitter Bootstrap? Yes
[?] Which modules would you like to include? angular-resource.js, angular-route.js
...
卡玛测试与grunt test
don't work right out of the box,所以你需要手动安装一些额外的依赖关系:
$ npm install karma-jasmine --save-dev
$ npm install karma-chrome-launcher --save-dev
在此之后,虽然,测试仍然会失败。从看起来好像咖啡脚本文件被解释为JavaScript的错误。
$ grunt test
Running "karma:unit" (karma) task
INFO [karma]: Karma v0.12.1 server started at http://localhost:8080/
INFO [launcher]: Starting browser Chrome
WARN [watcher]: Pattern "/Users/karl/projects/resources/test/mock/**/*.coffee" does not match any file.
INFO [Chrome 33.0.1750 (Mac OS X 10.9.2)]: Connected on socket W35K_wuKKVx2BweeP-F2 with id 48564140
Chrome 33.0.1750 (Mac OS X 10.9.2) ERROR
Uncaught SyntaxError: Unexpected token >
at /Users/karl/projects/resources/app/scripts/app.coffee:7
Chrome 33.0.1750 (Mac OS X 10.9.2) ERROR
Uncaught SyntaxError: Unexpected string
at /Users/karl/projects/resources/app/scripts/controllers/header.coffee:4
Chrome 33.0.1750 (Mac OS X 10.9.2) ERROR
Uncaught SyntaxError: Unexpected string
at /Users/karl/projects/resources/app/scripts/controllers/main.coffee:4
Chrome 33.0.1750 (Mac OS X 10.9.2) ERROR
Uncaught SyntaxError: Unexpected string
at /Users/karl/projects/resources/test/spec/controllers/main.coffee:3