Skip to content

Instantly share code, notes, and snippets.

@yutin1987
Created February 26, 2017 07:43
Show Gist options
  • Save yutin1987/0c4b5489bfc4cd80b88ad1238f84e641 to your computer and use it in GitHub Desktop.
Save yutin1987/0c4b5489bfc4cd80b88ad1238f84e641 to your computer and use it in GitHub Desktop.
mock knex
import knex from 'knex';
export const query = jest.fn(() => Promise.resolve([]));
const client = class extends knex.Client {
_query = query;
acquireConnection = () => Promise.resolve({});
processResponse = resp => resp;
releaseConnection = () => Promise.resolve();
};
export default () => knex({ client });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment