Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('can validate using plugin', async () => {
// The third argument of `render` is a callback function that receives the
// Vue instance as a parameter. This way, we can register plugins such as
// VeeValidate.
const {getByPlaceholderText, queryByTestId, getByTestId} = render(
Validate,
{},
vue => vue.use(VeeValidate, {events: 'blur'}),
)
// Assert error messages are not in the DOM when rendering the component.
expect(queryByTestId('username-errors')).toBeNull()
const usernameInput = getByPlaceholderText('Username...')
await fireEvent.touch(usernameInput)
// After "touching" the input (focusing and blurring), validation error
// should appear.
expect(getByTestId('username-errors')).toHaveTextContent(
/the username field is required/i,
)
})