xolvio / cleaner Goto Github PK
View Code? Open in Web Editor NEWGives you methods to clear your Mongo database and collections for testing purposes
Home Page: https://atmospherejs.com/xolvio/cleaner
License: MIT License
Gives you methods to clear your Mongo database and collections for testing purposes
Home Page: https://atmospherejs.com/xolvio/cleaner
License: MIT License
I haven't tested this, but the code seems like it won't work on the client side because of this line. Meteor won't let an untrusted code use an arbitrary Mongo selector with collection.remove
.
This might be a problem when doing client integration tests.
If that's the case, how about implementing something like this PR by @riebeekn?
sungwoncho/factory-boy#3
If the 'audit-argument-checks' package is installed, an invocation of 'resetDatabase' from the client will fail because the Meteor method definition is not checking the options
argument.
Cool package!
Since I'm running this before every scenario, it would be great to have a way to turn off the logging output. (such as using https://atmospherejs.com/practicalmeteor/loglevel)
This package will need to be updated for fibers-free meteor:
Any chance you could tag a new release on Atmosphere so we can take advantage of the excludedCollections
functionality?
Just upgraded my meteor project to version 1.6.1 and my meteor server tests starts to fail.
They are work fine on version 1.6.0.1 and fail on 1.6.1 with error on calling beforeEach hook:
Error: timeout of 2000ms exceeded. Ensure the done() callback is being called in this test
Tried to use this.timeout() function with no luck.
BTW, I'm using meteortesting:mocha package.
Since the resetDatabase
method call doesn't check the options
argument, it fails to run when audit-argument-checks
is enabled, with the following error:
Exception while invoking method 'xolvio:cleaner/resetDatabase' Error: Did not check() all arguments during call to 'xolvio:cleaner/resetDatabase'
A simple fix to this would be to check the options argument with:
check(options, Match.Optional(Object))
.
I'd trying to use a separate NODE_ENV
for testing: NODE_ENV=test meteor ...
But xolvio:cleaner currently checks process.env.NODE_ENV !== 'development'
and blows up.
I think it would be better and more flexible to change this check to: process.env.NODE_ENV === 'production'
, as this will allow other environments.
Does this sound like a good idea?
MongoError: cannot remove from a capped collection: meteor.__kdtimeevents
The following error occurs when package testing:
W20160524-15:04:50.610(-6)? (STDERR) ReferenceError: MongoInternals is not defined
W20160524-15:04:50.610(-6)? (STDERR) at packages/xolvio:cleaner/cleaner.js:36:15
I have figured out the solution. Basically, in the case of package testing, explicitly add 'mongo' (and aswell as underscore) as dependencies. I'll make a pr.
Apparently you can't remove documents from a capped collection: https://docs.mongodb.org/manual/core/capped-collections/
I'm getting this error:
MongoError: cannot remove from a capped collection: meteor.useful:logs/logs
@ Object.Future.wait (/Users/joshua/.meteor/packages/meteor-tool/.1.1.3.1rio88++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:398:15)
@ packages/meteor/helpers.js:119:1
@ packages/xolvio_cleaner.js:41:5
The annoying thing is that this crashes my entire test, the only way to get my tests working is to temporarily convert my collection to an ordinary collection by commenting out the code that makes a capped collection.
If I get a chance I'll look into adding a pull request for this, it looks like it should be pretty simple to fix.
In the mean time fixing #6 would be a nice workaround.
I'm populating meteor_accounts_loginServiceConfiguration
on Meteor.startup()
only, would be nice to be able to keep that one collection's content accross scenarios.
The Title pretty much describes it.
I get a warning on the server console that says:
[MONGODB DRIVER] Warning: collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead.
I can see that it is triggerd from the xolvio:cleaner
package by setting the NODE_OPTIONS="--trace-warnings"
environment variable:
I am trying to use this package in a package test that uses practicalmeteor:mocha
as the test runner. My test is server side only when I am getting the following error:
Error: MongoInternals is not defined
at resetDatabase (packages/xolvio_cleaner/packages/xolvio_cleaner.js:22:1)
at Hook.<anonymous> (packages/local-test:tdb:organizations/tests/methods.js:8:7)
at run (packages/practicalmeteor:mocha-core/server.js:56:16)
This is my Package.onTest
:
Package.onTest(function(api) {
api.use([
'ecmascript',
'mongo',
'practicalmeteor:mocha',
'xolvio:cleaner',
'practicalmeteor:chai',
'tdb:organizations'
]);
api.addFiles([
'tests/index.js',
'tests/methods.js'
]);
});
What could be wrong?
UPDATE - 5 minutes later
I could make my test work by not using this package with the following approach:
if (Meteor.isServer) {
Meteor.methods({
'test.cleanOrganizations': () => Organizations.remove({})
});
describe('tdb:organizations - methods', () => {
beforeEach( done => {
Meteor.call('test.cleanOrganizations', done);
});
...
So I think the problem is not related with the mongo
dependency because my collection is using it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.