- Notifications
You must be signed in to change notification settings - Fork1
Wrap Jest or Mocha tests in Objection transactions
License
NotificationsYou must be signed in to change notification settings
smartlyio/objection-transactional-tests
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Run tests inJest orMocha inObjection.js transactions. This starts a new transaction at the beginning of each tests and does a rollback at the end of it, reverting the database to the state it was in before the test.
import{transactionPerTest}from"objection-transactional-tests";describe("examples",()=>{transactionPerTest();it("database interactions",()=>{// do something that touches database});});
Note that any database changes done inbeforeAll
won't be cleaned up.
The setup can be added to test setup script to apply it automatically for alltests. This will ensure that no test pollute the test database, but also addsoverhead to tests that do not use the database.
About
Wrap Jest or Mocha tests in Objection transactions
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.