Hi everyone,
When stepping through the “Testing” part of the tutorial at https://www.meteor.com/tutorials/blaze/testing , using the exact code provided at https://github.com/meteor/simple-todos/blob/9a08b96bae018a4ecb3d23dada624accdb817cb0/imports/api/tasks.tests.js , I am getting the following failed test:
Tasks
methods
can delete owned task ‣
Error: Meteor.userId can only be invoked in method calls. Use this.userId in publish functions.
at AccountsServer.userId (packages/accounts-base/accounts_server.js:82:13)
at Object.Meteor.userId (packages/accounts-base/accounts_common.js:223:19)
at Object.tasksRemove (imports/api/tasks.js:39:31)
at Context. (imports/api/tasks.tests.js:35:20)
at run (packages/practicalmeteor:mocha/meteor/src/setup/SetupRunnables.js:113:18)
at Context.wrappedFunction (packages/practicalmeteor:mocha/meteor/src/setup/SetupRunnables.js:125:16)
at callFnAsync (packages/practicalmeteor:mocha/lib/runnable.js:338:8)
at Test.Runnable.run (packages/practicalmeteor:mocha/lib/runnable.js:290:7)
at Runner.runTest (packages/practicalmeteor:mocha/lib/runner.js:422:10)
at packages/practicalmeteor:mocha/lib/runner.js:533:12
I am guessing this is not what is supposed to happen. Is it possible to explain to a Meteor newbie what is causing this to occur? I’m not even sure which line of the test is invoking Meteor.userID.
EDIT: I posted this too quickly - the offending line is clearly " if (task.owner !== Meteor.userId()) {" in imports/api/tasks.js. But I’m not sure how to address it.