jbrumwell / mock-knex

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

Protect replace from modifying the prototype #138

Open danthegoodman opened 1 year ago

danthegoodman commented 1 year ago

mock(Knex) is storing the original functions on a replacement object, but when being set lodash is storing it on the real object prototype. This change modifies the replacement storage to put the function on a renamed prototype object much like the constructor.

This allows unmock(Knex) to properly restore all mocked functions.

Fixes #126