4

Saving Form Data

The preceding chapter introduced Playwright and SvelteKit routes. The data in our /birthdays route was hardcoded. In this chapter, we’ll force the real implementation of the load function by adding the ability to add new birthdays into the system.

Figure 4.1 shows the new form we’ll be building. It is attached to the bottom of the birthday list at the /birthdays route:

Figure 4.1 – The form for adding a new birthday

Figure 4.1 – The form for adding a new birthday

This chapter covers the following key topics:

  • Adding a Playwright test for data input
  • Test-driving a SvelteKit form
  • Test-driving a SvelteKit form action

By the end of the chapter, you’ll have a good understanding ...

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.