Skip to content

Instantly share code, notes, and snippets.

@gataky
gataky / knex.js
Last active September 26, 2019 06:53
Mocking knex within jest
let methods = new Set(require('knex/lib/query/methods').concat(['get', 'raw']))
module.exports = function() {
let calls = {}
let queue = []
function knex() {
return new Proxy(jest.fn().mockImplementation(), {
get: function get( object, property ) {
if ( methods.has(property) ) {