mock-knex
mock-knex copied to clipboard
Tracks not wanted DB instances
Hey, first of all thank you for this package.
I was running my tests with mock-knex and after debugging some cases, I've realised that it's not very consistent that if you are connecting to different dbs with the same client and you mock one of them, then all will be tracked.
Please let me know if I'm doing something wrong. Here is the example:
const knex = require('knex')
const mockDb = require('mock-knex')
const db1 = knex({
client: 'pg'
})
const db2 = knex({
client: 'pg',
connection: {
host: '127.0.0.1',
user: 'postgres',
password: 'postgres',
database: 'postgres'
}
})
mockDb.mock(db1)
const tracker = mockDb.getTracker()
tracker.install()
tracker.on('query', function (query) {
query.response([1, 2])
})
db2.table('table').select('*').then(console.log) // prints [1, 2] !!