Unit Test: Format Validation

Let’s learn to write a unit test to implement a format constraint.

Defining the test

This unit test restricts the name field to only contain letters and spaces. To define this one, we’ll set a name containing an emoji character on the user and assert validation failure.

Here’s the test:

Get hands-on with 1200+ tech skills courses.