摩卡测试,之前(每个)没有运行?

时间:2012-08-10 10:56:40

标签: unit-testing node.js mongoose mocha

我正在尝试测试我的mongoose模型:

Todo =要求“../../../ 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

出于某种原因,beforebeforeEach没有触发,为什么会这样?

1 个答案:

答案 0 :(得分:2)

似乎你之前我的情况不正确。

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

before (done) ->
     console.log 'In b4'