Closed luizpmonteiro8 closed 2 years ago
Thank you for reporting this issue,
It depends on the code that is inside knexfile
, can you share it?
I guess that knexfile
file should return a knex
instance not the mock.
Instead of
jest.mock('../knexfile', () => {
return {
client: require('knex-mock-client').MockClient,
};
});
It the mock should be
jest.mock('../knexfile', () => {
return knex({ client: MockClient });
// ------^ this is a real instance of knex with a mock client (instead of mysql client or any other DB client)
});
i make this,
jest.mock('../config/db', () => {
const { Model } = require('objection');
const knex = require('knex')({ client: require('knex-mock-client').MockClient });
// knex.migrate.latest([{ client: require('knex-mock-client').MockClient }]);
Model.knex(knex);
module.exports = knex;
return knex;
});
remove migrate and works, thanks a lot for the help!
As you can see I made the code a little different, but it works, it shows this error, what can I do to fix it? thanks
I didn't use this
save
test.js
error