What DB does Factory.create() insert into?

Hi!

I’ve been following the guide on creating test data at https://guide.meteor.com/testing.html#generating-test-data .

I’ve read through the documentation of Factory at https://atmospherejs.com/dburles/factory and am still a little confused as to what it does.

I’m reading the ‘define’ method as being sort of like a constructor for test Documents that belong to some Collection.
I see that you can then instantiate a Document from this definition by using the Create method. Documentation states that create method inserts that document into MongoDB. What DB is this, a test one ? I don’t think it’s the actual app’s one because I ran a count() on my collection before and after running the test and it did not change.

The Factory.build function is supposed to be like Create, except that it does not insert into the DB. This would be fine, except I see that the resulting object does not have access to helper methods.

Documentation for StubCollections seemed to be more intuitive. It simply creates a LocalCollection. What’s the general consensus to use for creating test data? Thanks!

1 Like

When you run Meteor in test mode, it builds to a temporary directory and launches it’s own mongodb instance. This means you can run both the app and the tests in watch mode at the same time without one interfering with the other

Thanks! Exactly the clarification I was looking for