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.js
file, add a new nesteddescribe
block with a single test, as shown in the following code snippet. It checks that if theerror
property is set on theform
prop, 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...