Chalkboard Planning Diagram

Member-only story

NgRx Unit Test Theory

Josh Hicks

--

Learn The Why Before The How

There are several different resources out there about how to test NgRx applications but I think there is a lack of resources talking about what to test and why. So, I thought I would add my musings about NgRx testing to help fill that gap. I will also use this as a reference for myself and will update it as I learn new things!

This will be theory only for now. I may add code examples in the future but, I think it’s important to think about things without code sometimes. Let’s get started!

General Unit Testing Theory

I think it’s helpful to start with a general concept of unit testing to keep us on track. If you want to learn more about unit testing in general check out this site.

Generally speaking, unit testing is about testing a unit of code in isolation. A unit could be several things but in most cases when working with JavaScript-based applications a unit is a function. We want to test that the function (AKA unit) behaves as expected. When we pass these parameters, it should return this result. That is a good fundamental starting place, to begin with, unit testing theory.

As we are writing tests we can ask ourselves questions about what we’re doing. Think of these as mental checkpoints. Here are some sample questions:

--

--

No responses yet