Skip to content

Instantly share code, notes, and snippets.

@AlexandrHoroshih
Created September 23, 2021 17:22
Show Gist options
  • Save AlexandrHoroshih/77c2a0c820a92bdde2a4c9d5195625da to your computer and use it in GitHub Desktop.
Save AlexandrHoroshih/77c2a0c820a92bdde2a4c9d5195625da to your computer and use it in GitHub Desktop.
test('stuff', async () => {
// create new forked scope, which is completly independent
const scope = fork({
// apply modifications like initial store values in this scope
values: new Map()
.set($myStore, "value"), // changed value in $myStore specifically for this scope
handlers: new Map()
.set(myFx, mockHandler) // changed effect handler to mock one for this scope
});
// launching event or effect, which triggers the logic we want to test
// we doing it just in our forked scope
await allSettled(startEvent, {
scope,
params: // params of startEvent
})
// check states of stores in this scope after all calculations ended
expect(scope.getState($myStore)).toEqual(...)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment