prime-simplereport
prime-simplereport copied to clipboard
Create factories for frontend unit testing
Description
As developers, we frequently have a need to produce units of data that are complex and high-specified but also arbitrary. In Java, we maintain a TestDataFactory which allows us to rapidly produce these data objects for use in unit testing. However, there is no parallel for the React application.
Proposed solution
Implement a test factory file that can produce instances of some of the common types and interfaces for data in SimpleReport
- Person
- Facility
- AoE responses
- And many more!
Additional context
Maybe using an existing library will make sense (Fishery looks neat!), but you may also find that we need little more than, e.g.:
const person = (data: Partial<Person>) => {
const default = {
/* some arbitrary data of type `Person` */
};
return Object.assign(default, data);
}