我的代码在这里(在coffeescript中):
describe "Chat", ->
it "should contain 1 message after insert()", ->
collection = new Meteor.Collection(null)
collection.insert({username:'guest', message : 'hi'})
expect(collection.find({}).count()).not.toBe(0 )
在Meteor中运行时,它会抱怨:
Error: TypeError: Cannot read property '_docs' of undefined
at [object Object].LocalCollection.Cursor._getRawObjects (/Users/user/WebstormProjects/mud-craft/.meteor/local/build/programs/server/packages/minimongo.js:512:18)
at [object Object].LocalCollection.Cursor.count (/Users/user/WebstormProjects/mud-craft/.meteor/local/build/programs/server/packages/minimongo.js:260:15)
at Object.<anonymous> (/Users/user/WebstormProjects/mud-craft/tests/jasmine/server/unit/sample_server_test.coffee:6:5)
但产品代码没问题。