【问题标题】:Jasmine with Coffeescript Unexpected string Syntax error茉莉花与 Coffeescript 意外的字符串语法错误
【发布时间】:2015-11-07 17:03:00
【问题描述】:

我在 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)

这是我的规范/支持/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

我错过了什么?

【问题讨论】:

  • 看来你还没有编译coffeescript代码。
  • @Bergi 是的,你是对的,我不是故意编译它,我以为 Jasmine 会自动理解它......我真的必须将我的 mainSpec.coffee 预编译为 mainSpec.js 吗?

标签: javascript coffeescript jasmine jasmine-node


【解决方案1】:

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

【讨论】:

  • 这对我有帮助。伟大的。但我很惊讶 Jasmine 没有编译咖啡脚本
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-01-24
  • 2017-01-15
  • 2014-12-12
  • 2011-10-26
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多