Closed throrin19 closed 5 years ago
Would you be able to use the sql
part of the query for uniqueness?
I pass ava in --serial
and it works fine with mock-knex :)
Glad to hear it @throrin19 :)
For example, this is my test to try if My model helper build correctly the queries :
const test = require('ava');
const tracker = require('mock-knex').getTracker();
test.beforeEach(() => {
tracker.install();
});
test.afterEach(() => {
tracker.uninstall();
});
test('fetchPage without pagination', async (t) => {
const users = [
userMock(),
userMock(),
];
tracker.on('query', (query) => {
t.is(query.method, 'select');
t.is(query.sql, 'select `user`.* from `user`');
query.response(users);
});
const response = await modelHelper.fetchPage({
model : 'User',
module : 'users',
});
t.is(response.length, users.length);
t.falsy(response.data);
t.not(typeof response.count, 'number');
});
Hello,
I try to use your module with Ava to test the database part of my project but I have a problem :
Ava execute all tests in parallel, and, with this processing, the
tracker.on('query')
capture query of other test randomly.