15
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 ...
Get Svelte with Test-Driven Development now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.