jbrumwell / mock-knex

A mock knex adapter for simulating a database during testing
MIT License
240 stars 71 forks source link

Add recorder much like nock has. #39

Open CodisRedding opened 8 years ago

CodisRedding commented 8 years ago

I was thinking that it would be a useful addition to add a .record() function, that would record the unmocked db calls and output the mock-knex code needed to mock those same calls.

jbrumwell commented 8 years ago

Is this what your thinking? https://github.com/node-nock/nock#recording, if so looks like an interesting feature.

CodisRedding commented 8 years ago

Yeah. That's it. It's been really useful for http calls. When I find some time I'd like to explore it a bit.

jbrumwell commented 8 years ago

That would be great :) you could use knex's query-response event, which should give you the sql query and the expected response :+1: