prime-simplereport icon indicating copy to clipboard operation
prime-simplereport copied to clipboard

Create factories for frontend unit testing

Open nathancrtr opened this issue 4 years ago • 0 comments

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);
}

nathancrtr avatar Nov 08 '21 23:11 nathancrtr