A library (v1.0.3) that patches mysql/mysql2 drivers to wrap each test in a database transaction, automatically rolling back after each test. Inspired by Rails, Laravel, and Spring testing patterns. Supports Knex, Kysely, Sequelize, TypeORM, MikroORM and any ORM/client using mysql or mysql2 drivers. Enables fast, isolated integration tests with a real database without manual cleanup. No recent updates. Import before your database client. ESM and CJS compatible.
npm install mysql-transactional-testsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to set up transactional tests with mysql driver: startTransaction before each test, rollback after, and unPatch in afterAll.
Import from 'mysql-transactional-tests/mysql' or 'mysql-transactional-tests/mysql2' accordingly.
Ensure 'mysql-transactional-tests/mysql' or '/mysql2' is imported before any mysql/mysql2 require/import.
Use `const { rollback } = await startTransaction();`Import from 'mysql-transactional-tests/mysql' or 'mysql-transactional-tests/mysql2'.
Use `import { startTransaction } from 'mysql-transactional-tests/mysql'` or `const { startTransaction } = require('mysql-transactional-tests/mysql')`.Ensure each test runs its own transaction; avoid manual transaction management inside test.