我正在 Coffeescript 中尝试 Jasmine,但是当我在终端中调用 jasmine
时,出现此错误:
/home/luca/tries/sourcemaps-demo/spec/mainSpec.coffee:1
nction (exports, require, module, __filename, __dirname) { describe 'A suite',
^^^^^^^^^
SyntaxError: Unexpected string
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at /home/luca/.nvm/v0.10.35/lib/node_modules/jasmine/lib/jasmine.js:63:5
at Array.forEach (native)
at Jasmine.loadSpecs (/home/luca/.nvm/v0.10.35/lib/node_modules/jasmine/lib/jasmine.js:62:18)
at Jasmine.execute (/home/luca/.nvm/v0.10.35/lib/node_modules/jasmine/lib/jasmine.js:145:8)
这是我的规范/support/jasmine.json:
{
"spec_dir": "spec",
"spec_files": [
"**/*[sS]pec.coffee"
],
"helpers": [
"helpers/**/*.coffee"
]
}
这是我的spec/mainSpec.coffee:
describe 'A suite', ->
it 'should return true', ->
expect(true).toBe true
我错过了什么吗?
最佳答案
jasmine
不支持coffee-script
。如果您想在 coffee-script
中编写测试,请使用 jasmine-node
$npm install -g jasmine-node
$jasmine-node --coffee spec/
.
Finished in 0.01 seconds
1 test, 1 assertion, 0 failures, 0 skipped
关于javascript - Jasmine 与 Coffeescript 意外的字符串语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32010073/