Test-Driving Svelte Stores
Stores are a useful mechanism for sharing state that exists outside of the normal Svelte component hierarchy. You can think of stores as global variables but with a protective mechanism – the subscribe
mechanism – that helps ensure that all components maintain a consistent view of each variable’s current value.
When it comes to writing tests for components that involve stores, you’ve got to write tests for two halves: the first half for the observation of the store value and the second half for the setting of the store value.
Because stores are an internal design decision, there’s no need to write a Playwright test specifically for the introduction of stores.
This chapter covers the following key topics:
- Designing a store for birthdays
- Writing tests for reading store values
- Writing tests for updating store values
By the end of the chapter, you’ll have a good understanding of writing...