Displaying SvelteKit form errors
In this section, we’ll add tests and functionality to support passing in a new form prop into the BirthayForm component.
Let’s start with a new test:
- In the
src/routes/birthdays/BirthdayForm.test.jsfile, add a new nesteddescribeblock with a single test, as shown in the following code snippet. It checks that if theerrorproperty is set on theformprop, then that error must be displayed somewhere on the page:describe('validation errors', () => { it('displays a message', () => { render(BirthdayForm, { form: { error: 'An error' } }); expect( screen.queryByText('An error') ).toBeVisible(); }); }); - Make that...