如何使用带有brush-with-chaplin样板的Sinon Js

时间:2014-09-11 09:55:22

标签: javascript coffeescript sinon brunch chaplinjs

我开始使用Brunch-with-Chaplin样板文件,但我想添加sinon和qunit。所以我将它们添加到bower.json并使用bower install <lib>安装它们。它工作得非常顺利但现在我想要访问这样的功能:

Model = require './model'

module.exports = class Collection extends Chaplin.Collection
  # Mixin a synchronization state machine.
  # _(@prototype).extend Chaplin.SyncMachine
  # initialize: ->
  #   super
  #   @on 'request', @beginSync
  #   @on 'sync', @finishSync
  #   @on 'error', @unsync

  # Use the project base model per default, not Chaplin.Model

    model: Model

    initialize: ->
        @on 'request', @reply

    reply: ->
        console.log QUnit # this works
        console.log Sinon # this error's
        console.log 'requested'

更新:

当我使用brunch build手动构建时,我收到了错误

error: [Error: Component JSON file     
"/Users/Simon/Development/myparcel/data/myparcel/bower_components/sinon/.bower.json"
must have `main` property. 
See https://github.com/paulmillr/read-components#README]

所以我没有任何运气就将"main":"sinon.js"添加到文件中。

1 个答案:

答案 0 :(得分:0)

您需要更改一点,您需要将"sinon.js"更改为"lib/sinon.js"console.log Sinonconsole.log sinon,因为Sinon使用的是sinon全局Sinon