Member-only story

Angular Unit Testing: Login

Tek Loon
2 min readJun 25, 2019

--

This article documented how I write units test for Login Features.

Before I started, I’ll have prepared

Isolated Test

I am only going to test component class logic for Isolated Test without rendering.

There are 5 test cases:

1.) Ensure the component is successfully created (Boilerplate Test Case)

2.) Ensure the component initial state is correct

3.) submitted should true and authError should be false when onSubmit function called.

4.) Verify the form field value updated correctly

5.) Form should be invalid when blank field entered

Shallow Test

The main test I focus in Shallow Test is template rendering. For e.g, I would ensure the button.click() will…

--

--

Tek Loon
Tek Loon

Written by Tek Loon

Coder and Writer. If you enjoy my stories— support me by https://www.buymeacoffee.com/tekloon so I can keep writing articles for the community.

Responses (1)