HergBot / musqrat

A lightweight, strongly typed wrapper for using MySQL in Node.JS
0 stars 0 forks source link

Create mocking util functions for table functions #10

Closed xHergz closed 2 years ago

xHergz commented 2 years ago

Since the library is most likely going to be used at the table level, we should provide an easy way to mock those top level actions so the user doesn't have to figure out how to mock the chains properly in Jest unless they want to. This was a pain point for me when using mongoose.

To Do:

End goal: I want to make one call to mock a top level action to return a specific result no matter how many methods are used in the chain.

const exampleMock = mockInsert(tableObject, results); // Returns a Jest spy
xHergz commented 2 years ago

Ended up being able to use a fake IDbConnection object to replace only the exec function.