Rob Bertram

Wasn’t able to find this information when googling it so wanted to share my solution. Here’s the helper function you’re looking for:

export function mockSvelteReadableValue<T>(readable: Readable<T>, value: T): void {jest.spyOn(readable,'subscribe').mockImplementation((mockConsumeState) => {
mockConsumeState(value);
return () => {
// this is the unsubscribe function which I haven't needed to do anything with (yet)
};
});
}///// implementationimport * as store from './store';it('should work', () => { mockSvelteReadableValue(store.foo, true); // do stuff
})

A quick explanation: Basically you just have to mock concepts in the store contract. If this can be improved, LMK!

--

--

Rob Bertram

Rob Bertram

“A language that doesn’t affect the way you think about programming is not worth knowing.”