11

Replacing Behavior with a Side-By-Side Implementation

In the previous two chapters you built out a fully formed repository and an API for accessing it. Now it’s time to complete the story arc by updating both the SvelteKit loader and form actions to use the API instead of the repository.

It’s worth pointing out that this isn’t a necessary step: it would be perfectly acceptable to keep the SvelteKit server pieces pointing directly at the repository.

But reworking our existing code to point at the new API endpoints will introduce you to two ideas: first, that of a side-by-side implementation, which is a way to use tests to replace the existing code while ensuring the test suite remains on Green. The second is the use of a test double to shield ...

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.