本文介绍了转换角度种子茉莉单元测试的CoffeeScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
作为练习,我想转换包括从爵士咖啡脚本角种子
回购善缘单元测试。特别是,我有与测试/单位/ directivesSpec.js
测试集,它定义了一个简单的增值服务的问题。这里是我的咖啡脚本code:
As an exercise, I am trying to convert the karma unit tests included in the angular-seed
repo from js to coffee script. In particular, I am having problems with the tests/unit/directivesSpec.js
test set, which defines a simple value service. Here is my coffee script code:
1 describe 'directives', ->
2 beforeEach module 'myApp.directives'
3
4 describe 'app-version', ->
5 it 'should print current version', ->
6 module ($provide) ->
7 $provide.value 'version', 'TEST_VER'
8 inject ($compile, $rootScope) ->
9 element = $compile('<span app-version></span>')($rootScope)
10 expect(element.text()).toEqual 'TEST_VER'
有似乎当咖啡脚本code围绕线编译成为一个问题 6
因为这样就变成了:
There seems to be a problem when the coffee script code is compiled around line 6
as this becomes:
module(function($provide) {
return $provide.value('version', 'TEST_VER');
});
和导致我的测试中失败,出现错误:
And causes my tests to fail with the error:
Error: [ng:areq] Argument 'fn' is not a function, got Object
http://errors.angularjs.org/1.2.4/ng/areq?p0=fn&p1=not%20a%20function%2C%20got%20Object
at /Data/src/ngfrontend-seed/app/vendor/angular/angular.js:78:12
at assertArg (/Data/src/ngfrontend-seed/app/vendor/angular/angular.js:1358:11)
at assertArgFn (/Data/src/ngfrontend-seed/app/vendor/angular/angular.js:1368:3)
如果我删除收益
语句,测试运行良好。谈到在文档的对于一些详细信息。
这篇关于转换角度种子茉莉单元测试的CoffeeScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!