Closed tills13 closed 6 years ago
In your asserts, are you trying to check what has been "saved" into a DB? Or are you just trying to check that create
is run with BUDGET_UNLIMITED
?
the first assert
is checking the result of the create
the second assert
is checking the "saved" value
it's more of an integration test, which I guess is a little out of scope for this project.
Integration tests are entirely possible with this mocking framework, however storing/retrieving results is not. The library is meant for mocking out the data for tests and returning controlled values. We do not store or retrieve data in any way.
If you want tests to run with an "mock" DB behind it so you can run tests that insert and then retrieve data, we recommend using native Sequelize with an in-memory SQLite DB. That will allow you to use Sequelize as you normally would and test data retrieval from an actual DB while also not polluting your real DBs. This is also the way the Sequelize team has recommended doing this sort of testing in the past.
Sorry about the confusion there. If I'm misunderstanding or if you have other questions don't hesitate to ask.
Nope that's perfect - as I thought about it more and more I came to the same realization. Trying to shoehorn something into an existing testing framework to speed things up - this is the result. Thanks!
I have a flow that looks like
in my tests, I am making sure that providing no input to the above produces a
Party
with aPartyBudget
with an unlimited budget.For reasons (mostly obfuscation), the default value isn't set at the model level.
It seems that
sequelize-mock
creates a new instance instead of returning the associated object (in fact,setBudget
is a noop).Am I SOL on this (i.e. beyond the scope of
sequelize-mock
?)