How to mock a whole store? #97
-
Hi, I'm unit-testing one service, that receives a store in the constructor. But I'm struggling to mock signal or computed signals, did someone already tried this? I'm using jest and jest-auto-spies. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @jaytonic Thanks a lot for starting this discussion. When mocking a store with exposed signals to the outside world, I would mock the signal return value, but otherwise let it stay a signal to conserve the inner mechanics. I guess, especially including getter semantics, this makes it a bit more involved to configure the testing libraries accordingly. I have answered your specific question on stackoverflow. I don't have much experience with Essentially, there are many ways to do it and I might do a blog post in the future, or cover it in the documentation, as soon as time permits. |
Beta Was this translation helpful? Give feedback.
Hi @jaytonic
Thanks a lot for starting this discussion.
Sidenote: In the docs I have covered how to test a store in isolation.
This would also include testing for advanced flows like signal changed value propagation etc. which is well covered in signalstory own test suite.
When mocking a store with exposed signals to the outside world, I would mock the signal return value, but otherwise let it stay a signal to conserve the inner mechanics. I guess, especially including getter semantics, this makes it a bit more involved to configure the testing libraries accordingly.
I have answered your specific question on stackoverflow. I don't have much experience with
jest-auto-spies
, though.Essenti…