when I work with japa test runner adonisJs 5 my test failed and got this error:
× Uncaught exception
Transaction query already complete, run with DEBUG=knex:tx for more info
1 completedError
node_modules/knex/lib/execution/transaction.js:396
2 anonymous
node_modules/knex/lib/execution/transaction.js:362
3 Client_MySQL2.trxClient.query
node_modules/knex/lib/execution/transaction.js:358
4 Runner.query
node_modules/knex/lib/execution/runner.js:123
5 ensureConnectionCallback
node_modules/knex/lib/execution/internal/ensure-connection-callback.js:13
6 Runner.ensureConnection
node_modules/knex/lib/execution/runner.js:300
7 Runner.run
node_modules/knex/lib/execution/runner.js:30
8 QueryRunner.executeQuery
node_modules/@adonisjs/lucid/build/src/QueryRunner/index.js:78
I don't know why I get this error in some of my tests in some of i don't
japa test runner adonisJs 5
I encountered the same issue and the issue for me was a missing await on a database call that returned a promise in one of my assertions,
so by the time the response was returned the global transaction in the test suite had already been rolled back
Once I added the await, the error was resolved, so I suggest you double check any async calls in your tests which you may not be awaiting a response for.