You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 24, 2021. It is now read-only.
I went through a problem when migrating my code into ES6 modules and found a solution that worked for me I'd like to propose for the guide:
I found StubCollection wasn't ideal when creating client-side tests. Problems:
I have a project where in the client-server ES6 module that defines the collection, we attach a simpleSchema and some other decorated items.
Those decorators don't get attached run if you create a client-side null collection
Other ES6 modules import the non-null version of the model even if your test doesn't because models are no longer global once they're placed under /imports
StubCollection is just one more piece of overhead that I found I could get rid of once I came up with an alternative solution.
My client-server collections are defined in model, publications are defined in collections and client-side tests are in client. When I had a Race model defined in ...model/Race.js which is defined as export default Race = new Meteor.Collection('Race'), StubCollection would create a null collection which wasn't getting decorated and a module in other might import a non-null version.
Instead of using CollectionStubber at all, I can define the collection like this in ...model/Race.js:
letRace;if(Meteor.isTest&&Meteor.isClient){Race=newMeteor.Collection(null);}else{Race=newMeteor.Collection('Race');}exportdefaultRace;//decorations begin here, whether its' a null or non-null collectionRace.schema=newSimpleSchema({organization_id: {type: String},racer_id: {type: String}});Race.attachSchema(Race.schema);
...
The text was updated successfully, but these errors were encountered:
We are going to make many updates to the guide in the next weeks and it's better to focus on issues with recent activity. If you think this issue is still relevant please open a new one.
I went through a problem when migrating my code into ES6 modules and found a solution that worked for me I'd like to propose for the guide:
I found StubCollection wasn't ideal when creating client-side tests. Problems:
Given a directory structure like this,
My client-server collections are defined in
model
, publications are defined incollections
and client-side tests are inclient
. When I had aRace
model defined in...model/Race.js
which is defined asexport default Race = new Meteor.Collection('Race')
,StubCollection
would create a null collection which wasn't getting decorated and a module inother
might import a non-null version.Instead of using CollectionStubber at all, I can define the collection like this in
...model/Race.js
:The text was updated successfully, but these errors were encountered: