-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test database not reset between tests #136
Comments
That is expected right now. We should probably do a better job communicating that. It sounds like you would like to have the database cleared between tests? Or between test runs? |
Yes, the database needs to be cleared to ensure that the starting conditions are the same every time. Otherwise you can get unrepeatable results. Jasmine appears to clear the database as my app runs through its initialization and sets up the database from the empty state. At the very least it needs to be cleared between test runs. I'm not sure I understand the exact distinction between tests and test runs. So I'm not sure how to answer the question if it has to be cleared between tests too. |
I agree that some kind of reset should happen. The question to me is who should be responsible for resetting (framework, Velocity, or user), and how often it should happen. Resetting the db after each test seems like it'd be too slow, but at the start of the test suite seems like it'd offer a good balance of speed and a clear starting point. |
I would think the logical place is in Velocity when the mirror is set up. Does that happen only once at the beginning of a suite of tests? Or does it happen before every test? Actually I think clearing the database should be very fast in Mongo as it is accomplished by deleting all of the DB files. |
Yeah I agree, following discussion from https://github.com/meteor-velocity/velocity/issues/39 it seems like this should already be implemented in the mirror? In the meantime, I'm using a utility method I wrote here.
|
I've found a slightly better temporary solution. If you have a
|
Is there a meteor method do get this done from Velocity? |
👍 Any news about this? How do you guys usually clear the DB after tests without modifying the actual mocha package? |
@carlosbaraza Although in my opinion this is not the best solution, what I ended up doing is remove every item in each collection manually using beforeEach(). I did this because my current permissions do not allow me to drop databases on the client side.
|
Hi @OminStyle, But what about cleaning the full database, not only the documents available in the client? I want to have a clean way to clear the database without compromising security, letting docs to be deleted from the client. Maybe I am missing still some point from Velocity. Is there some way to set up a server method only callable from tests where I could clear the database? |
@carlosbaraza Agree that this isn't ideal, but couldn't you simply add the methods in a |
Hi @ryneeverett, thank you, that's an interesting point. I am still kind of new on the Meteor world, so I am figuring out the best way to do things. That might be my solution for the moment. Do you have some example repository where this is being done? |
For the moment I could not find someone doing such a debug package to clear the database via methods. However, I found a cool well known package example of the usage of |
Try this one for clearing the database:
|
Here's my implementation (and a mocha example): |
Is this the expected behavior for Mocha/Velocity?
The text was updated successfully, but these errors were encountered: