1

我正在尝试测试我的mongoose模型,例如:

待办事项 = 需要“../../../app/todos/Todo”

describe "Todo", ->
describe "Basic CRUD", ->

    before: (done) ->
        console.log "In b4"
        Todo.remove {}, (err) ->
            console.log "removed"
            done err

    it "can be added to database", (done) ->
        todo = new Todo
            title: "New todo"
        todo.save (err) ->
            if !err
                Todo.find { title: "New todo" }, (err, docs) ->
                    docs.length.should.equal 1
                    done(err)
            else 
                done err

出于某种原因,before或者beforeEach没有触发,这是为什么呢?

4

1 回答 1

2

看来你之前我的格式不正确。

应该删除之前的':'...应该是:

before (done) ->
     console.log 'In b4'
于 2012-08-10T12:47:37.047 回答