Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Wrap Jest or Mocha tests in Objection transactions

License

NotificationsYou must be signed in to change notification settings

smartlyio/objection-transactional-tests

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.

Usage

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

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp