ngx-store icon indicating copy to clipboard operation
ngx-store copied to clipboard

Mocking SharedStorage in tests

Open BojanKogoj opened this issue 4 years ago • 3 comments

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.

BojanKogoj avatar Mar 09 '20 11:03 BojanKogoj

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.

DanielKucal avatar May 12 '20 11:05 DanielKucal

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 avatar May 12 '20 15:05 BojanKogoj

@BojanKogoj, I think you can fire sharedStorageService.clear() before each test to have a fresh state 🤔

DanielKucal avatar Jul 31 '21 13:07 DanielKucal