【问题标题】:SyntaxError: Unexpected token * with coffeescript when run on codeshipSyntaxError: Unexpected token * with coffeescript 在 codeship 上运行时
【发布时间】:2016-05-07 17:10:02
【问题描述】:

我无法让我的 mocha 测试在 Codeship 上运行。这些在本地工作。我已经删除了 repo 并运行了npm install。仍然在本地工作,但不是远程工作。

我不确定这是否是 codeship 尝试运行测试时出现的咖啡脚本编译错误,但没有太多关于他们的平台对该语言的支持的信息。

我是否遗漏了一些我必须添加到我的代码测试环境中的东西?不知道为什么代码在本地会很好,但会破坏 codeship 中的所有内容。

本地运行时:

Debugger listening on port 5858


  Verify codeship works
    Ok should eql Ok
      ✓ should not post to the public channel


  1 passing (487ms)

代码测试结果:

debugger listening on port 5858

/home/rof/src/github.com/sprk-platform/tracker-bot/test/conversation_test.coffee:27
return function*() {
^
SyntaxError: Unexpected token *
at Module._compile (module.js:439:25)
at Object.loadFile (/home/rof/.nvm/v0.10.45/lib/node_modules/coffee-script/lib/coffee-script/register.js:16:19)
at Module.load (/home/rof/.nvm/v0.10.45/lib/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at /home/rof/.nvm/v0.10.45/lib/node_modules/mocha/lib/mocha.js:219:27
at Array.forEach (native)
at Mocha.loadFiles (/home/rof/.nvm/v0.10.45/lib/node_modules/mocha/lib/mocha.js:216:14)
at Mocha.run (/home/rof/.nvm/v0.10.45/lib/node_modules/mocha/lib/mocha.js:468:10)
at Object.<anonymous> (/home/rof/.nvm/v0.10.45/lib/node_modules/mocha/bin/_mocha:403:18)
at Module._compile (module.js:456:26)
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 Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:945:3

测试文件:

expect = require('chai').expect
should = require('chai').should

Helper      = require('hubot-test-helper')
helper = new Helper('../scripts/events.coffee')

co          = require('co')
Promise     = require('bluebird')

describe 'Verify codeship works', ->

  beforeEach ->
    @room = helper.createRoom()
    return

  describe 'Ok should eql Ok', ->

    beforeEach ->
      co =>
        yield @room.user.say '1', 'hello'
        return

    it 'should not post to the public channel', ->
      expect("ok").to.eql "ok"
      return

Events.coffee:

module.exports = (robot) ->
  robot.on 'some-event', (some, data) ->
    robot.messageRoom 'room1', "got event with #{some} #{data}"

  robot.respond /send event$/i, (msg) ->
    robot.emit 'response-event',
      content: 'hello'

包.json:

{
  "dependencies": {
    "hubot": "latest",
    "hubot-brain-inspect": "0.0.1",
    "hubot-conversation": "^1.0.3",
    "hubot-diagnostics": "0.0.1",
    "hubot-env": "0.0.2",
    "hubot-google-images": "^0.2.6",
    "hubot-google-translate": "^0.2.0",
    "hubot-help": "^0.1.3",
    "hubot-heroku-keepalive": "^1.0.2",
    "hubot-maps": "0.0.2",
    "hubot-pugme": "^0.1.0",
    "hubot-redis-brain": "0.0.3",
    "hubot-rules": "^0.1.1",
    "hubot-scripts": "^2.16.2",
    "hubot-shipit": "^0.2.0",
    "knwl.js": "^1.0.2",
    "nlp_compromise": "^3.0.8",
    "qs": "^6.1.0",
    "coffee-script": "latest"
  },
  "engines": {
    "node": "0.10.x"
  },
  "scripts": {
    "test": "node_modules/.bin/mocha --opts ./test/mocha.opts"
  },
  "devDependencies": {
    "bluebird": "^3.3.5",
    "chai": "3.5.0",
    "co": "4.6.0",
    "coffee-errors": "^0.8.6",
    "hubot-mock-adapter": "^1.0.0",
    "hubot-test-helper": "latest",
    "mocha": "latest",
    "mocha-retry": "^0.1.0",
    "mockery": "latest",
    "sinon": "latest",
    "sinon-chai": "latest"
  }
}

还有 mocha.opts:

--compilers coffee:coffee-script/register
--ui tdd
--reporter spec
--recursive
--debug
--inline-diffs

还尝试添加--require coffee-script

【问题讨论】:

    标签: coffeescript mocha.js codeship


    【解决方案1】:

    看起来问题是节点版本不一致。本地是 5.6.0 和 package.json 需要 0.10.x。破坏测试的是 yield,它是 ECMA6 的一部分。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-12-15
      • 1970-01-01
      • 2013-02-12
      • 2017-09-10
      • 2022-10-05
      • 2017-04-06
      • 2018-01-05
      相关资源
      最近更新 更多