Test Only Behavior

Yudi Supriyadi
1 min readNov 4, 2021

--

We don’t need to test all aspects in application. Our goal is to make sure our application runs in the correct way.

No need test for Static Text

For example we don’t need to test if a text appears in the screen like below.

test('User can see "Login" text in Login Form', () => {
expect(screen.getByText('Login')).toBeInTheDocument();
});

Because it is trivial and not urgent.

No need test for CSS Style

Visual aspect is something that can’t be checked by automated test. It only can be checked by human eye. So it is manual job.

How about testing an image? We can’t check image is rendered correctly but we can check image url that passed to <img> is what we expect.

But we need test Behavior

Our concern is on behavior. Behavior contains logic that easily can be wrong and an application contains huge logic. This logic if wrong can hurts people like reducing bank’s customer balance.

Example behavior:

  • Inmate and booking fields in Secondary Header should be populated by previous selected inmate and booking in search overlay.
  • If user has not selected inmate and booking then redirects user to homepage

--

--

No responses yet