Open claremacrae opened 1 year ago
Thank you for creating this library. It has made it possible to test a svelte component in Jest.
There are some places where we want to make multiple calls in the same it function, instead of in 2 separate it blocks.
it
(This is because we wish to collate the outputs of a number of calls with different inputs in to a single test output)
For example, this works:
it('test1', async () => { await doSvelteStuff(); }); it('test2', async () => { await doSvelteStuff(); });
However, if we need this to be in the same block.
it('test1And2', async () => { await doSvelteStuff(); await doSvelteStuff(); });
Then it gives us this kind of error:
Found multiple elements with the text: Apply
What we would like to be able to is clean up the svelte state manually in the middle of an it, something like either:
it('test1And2', async () => { await doSvelteStuff(); svelte_jester.cleanUp(); // simulate effect of afterEach() svelte_jester.startUp(); // simulate effect of beforeEach() await doSvelteStuff(); });
Or...
it('test1And2', async () => { await doSvelteStuff(); svelte_jester.reset(); await doSvelteStuff(); });
Or maybe there is already a way to do this?
If it helps, we (myself and @isidore) would be happy to pair with someone on this.
This should have nothing to do with this library. Is doSvelteStuff(); an side-effect?
doSvelteStuff();
Maybe you can try adding await tick(); in between. This lets Svelte re-calculate all expressions.
await tick();
Thank you for creating this library. It has made it possible to test a svelte component in Jest.
There are some places where we want to make multiple calls in the same
it
function, instead of in 2 separateit
blocks.(This is because we wish to collate the outputs of a number of calls with different inputs in to a single test output)
For example, this works:
However, if we need this to be in the same block.
Then it gives us this kind of error:
What we would like to be able to is clean up the svelte state manually in the middle of an
it
, something like either:Or...
Or maybe there is already a way to do this?
If it helps, we (myself and @isidore) would be happy to pair with someone on this.