Hi!
I’m trying to unit test some Meteor Methods that check
if (!this.userId)
I’ve been able to stub Meteor.userId
successfully, but same fix doesn’t work for this.userId
and I’m also running into issues with getting this to work for multiple unit tests.
I’ve spent a lot of time on this and realized I can simply just do
if (!Meteor.isTest && !this.userId)
Seems simple enough. However, I don’t know if it’s good practice to check environments in production code. What does the community think about this. I don’t think it’s something I’d introduce frequently. Thanks!