BlinkUX/sequelize-mock

Tests fail on trying to access model's .prototype

toxuin opened this issue · 1 comments

I've overrided a .toJSON method on a certain model and it throws an error when used with this library.

Sequelize version: 4.4.2,
Here is the chunk of code in charge:

Page.prototype.toJSON = function toJSON() { ... };

Here is a link on Sequelize's docs that I've used

Am I doing something wrong?..

Thanks!

Sequelize 4.x isn't quite fully supported yet. Unfortunately because of how much they changed under the hood it has been tough to accommodate both the 3.x and 4.x versions. Check #33 for more information on that specifically.

This issue you're seeing here actually hits the nail on the head unfortunately with the issue in the differences. With Instances being instances of Models in v4, it doesn't quite map back to v3 functionality as well.

As a really awful monkey patch, you could in theory set Page.prototype = Page.Instance.prototype and it may work enough to get you further. Though I can't promise that you'll get completely expected results in other places.