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...