-
Book Overview & Buying
-
Table Of Contents
Svelte with Test-Driven Development
By :
This short chapter covered some important concepts for testing Svelte stores: first, how to test the two halves of observing and setting Svelte store values, and second, how you can rename the store import so that it’s more readable within your tests. In our case, that meant renaming birthdays as birthdaysStore.
You’ve also seen how to call the store’s set and subscribe methods within your tests, and how to use Svelte’s $set function on the component instance to update props to a previously rendered component.
Taken together, these techniques highlight how advanced Svelte features are still testable at the unit level if that’s desired. Of course, you might get just as much value from writing Playwright tests that can happily ignore the internal mechanics of Svelte stores.
The next chapter covers a more complicated topic: service workers.