expect(Meteor.publishFunctions).toBeDefined(); // fails
This fails for me on server side. I’ve read the source code of meteor-stubs and I thought it was stubbing that for me.
I’m probably doing something wrong but it’s not clear to me what it is.
Sanjo
May 27, 2015, 1:10pm
2
This is not a standard Meteor method. From which package is this?
Maybe I’m getting things messy.
I mean this: https://github.com/meteor-velocity/meteor-stubs/blob/master/index.js#L211
I’m trying to test a publication, like this:
it("should return premium content to logged in users", function () {
// SETUP
var thisContext = {
userId : true
};
var expectedCursor = 'chapter_cursor1';
var _query = true, _modifiers = true;
Chapters.find = function(query, modifiers) {
_query = query;
_modifiers = modifiers;
return expectedCursor;
};
// EXECUTE
var actualCursor = Meteor.publishFunctions['chapters'].apply(thisContext);
// VERIFY
expect(actualCursor).toBe(expectedCursor);
This file has been truncated. show original
Sanjo
May 27, 2015, 3:52pm
4
This should (only) work in server unit mode. If not I can have a look.
Hmmm I haven’t done anything to differentiate unit and integrations tests. I think that’s why.
Here is the project: https://github.com/gabrielhpugliese/statuspage
I’ve just created that unit folder on the only package the project has. I suppose I had to do something more than that.
Forgot to mention that I’m running with command VELOCITY_TEST_PACKAGES=1 meteor test-packages --driver-package velocity:html-reporter
Sanjo
May 28, 2015, 12:05am
7
Package testing only uses the Server Integration and Client Integration mode. So the stubs are not used.
I think you can test your publication with a client integration test by using Meteor.subscribe and then check the collection for the expected documents.
Any possibility to patch the Meteor.publish function before the execution of code?
Sanjo
May 29, 2015, 5:28pm
9
No. But I think you can access your publish functions with Meteor.server.publish_handlers
(Source: https://github.com/meteor/meteor/blob/master/packages/ddp/livedata_server.js#L1428 )