ngx-store
ngx-store copied to clipboard
Mocking SharedStorage in tests
For some reason tests override each others state when using @SharedStorage()
.
Is there a way I could mock decorator, so values wouldn't be shared in tests?
To make it even worse this only happens on CI server, which makes it hard to debug.
Why don't you want the values to be shared in tests, like it'll be in the app? I think you can set initial value in class constructor for the cases you want to override stored value.
I have test A that uses shared object X in component. Test B has uses shared object Y in tests, but somehow ends up with X and fails because of this. These two tests use same shared property, but aren't even for the same component. For testing purpose I'm fine with these shared properties to behave as if they're not shared at all.
@BojanKogoj, I think you can fire sharedStorageService.clear() before each test to have a fresh state 🤔