Closed msio closed 7 years ago
Hi @msio777 - are you importing your publication file in your test file? For example, if you're calling your Meteor.publish()
in a publications.js
file, make sure you:
import 'some/path/publications.js';
in your test file.
thanks a lot man you were right with import :) but unfortunately
describe('lists.public', function () {
it('sends all public lists', function (done) {
// Allows us to look at the output of a publication without
// needing a client connection
const collector = new PublicationCollector();
collector.collect('interests', (collections) => {
console.log(collections);
//chai.assert.equal(collections.Interests.length, 3);
done();
});
});
});
console.log(collections) is {} and I imported all related js files
Are you using the factory
package from the todos app? If so define and create your test data before calling your test with the PublicationCollector
in it. By doing this you're manipulating your test collection, which ends up being caught by the PublicationCollector
, so it then knows to publish the captured collection data. So something like:
...
before(function () {
Factory.define('product', products, {
productId: faker.random.number(),
productName: faker.random.words(),
productUrl: faker.internet.url(),
productImage: faker.image.imageUrl(),
variationId: faker.random.number(),
variationName: faker.random.words(),
status: faker.random.word(),
});
_.times(3, () => {
Factory.create('product');
});
});
...
it('should publish all products if logged in', function (done) {
const collector = new PublicationCollector({ userId });
collector.collect('products.all', (collections) => {
chai.expect(collections.products.length).to.equal(3);
done();
});
});
...
I'm planning on publishing a publication-collector
package soon, that will have expanded docs helping explain all of this.
Thanks a lot I finally unterstood the concept but still this kind of error
this is my code
describe('publications', function () {
before(function () {
Factory.define('interest', Interests,{
name: 'Dance'
});
Factory.create('interest');
});
it('all interests', function (done) {
const collector = new PublicationCollector();
collector.collect('interests', (collections) => {
console.log(collections);
done();
});
});
});
I am using right know factory from todo app
I have this exact issue, but its intermittent. So I thought collector.collect is being asynchronous, and therefore I wrapped it with a promise, even then I get {} from publication-collector.
Hi, I tried publication-collector package from todos app and unfortunately I got this error
I test my publication in publications.test.js it looks like that my publication can not be found Thanks for any help. Is there any other way how I can test publications on server ? Best Regards Michal