Closed demisx closed 9 years ago
I use a beforeEach
hook to truncate all tables and re-seed them. With especially large test suites and seed data sets that might pose problems but for my use cases it's always fine.
Yeah, I thought about that. Really miss database cleaner gem we had in Rails. :) Can you please refer me to the project where you are doing it. I'd be interested to check it out.
Project isn't public but I've been asked about this before and published my (very simple) test script:
Thank you, sir. This helps!
Hi Ben, I am running my API tests using
supertest
package. Some of these test create records in the database that affect total counts. Is there an approach you can recommend for returning DB to previous state after each test? I realize I can probably manually delete each model that I create in test, but wondering if there is a better, more automated approach. Maybe taking a DB snapshot before each test and restoring it after each test. Can you recommend anything from your experience?