felixmosh / knex-mock-client

A mock client for knex which allows you to write unit tests with DB interactions

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Confusing debug of test at bindings approach

andregosling opened this issue · comments

Hello guys. I'm starting with unit testings with knex, and fall into this library, which a first point of view seems to solve my problem, but i find a little confuse the approach to check the input of a update at the database. I usually use objects from all of my 'update' operations using knex, and use to expect this calls using objects too.

However, the method that knex-mock-client provides to me assert this data is on bindings array of update history. What defines the position of this items on the array? If my entity changes, the position may change too? If the position changes, i will need to write a console.log at my test to get again the correctly position of the array for the field that i'm trying to assert? I'm very confusing about that.

Hi, @andregosling

This lib provide you a way to not interact with a real DB.
You define your mock response, call your method under test (which calls to DB), and check the response of this call.

I'm not sure what is the confusing part, can you elaborate? can you provide an example?

@andregosling did my explanation helped you?