Model Factories
Learn how to use factory classes to clean up our test code.
We'll cover the following
When we write tests, we often need to generate some dummy data that we can run through the component we are testing. We could store some simple dummy data in a plain JavaScript object. However, if we’re working with many data objects, we want to encapsulate this kind of data in a model class. Take a look at the example below, where we use a model factory to help us handle this logic. We have created two new files:
Get hands-on with 1200+ tech skills courses.