Skip to content

Fine-grained reactivity for real-time report #3086

@nicojs

Description

@nicojs

I want to introduce fine-grained reactivity to the HTML report.

Current situation

In the current situation, real-time updates are implemented ad hoc. This means that metrics are used to calculate the model. Subsequent updates result in recalculating the whole model. Code is rendered and drawn on the screen. To get acceptable performance, changes that are streaming in are buffered. I think this makes it unusable for big code files (like the one found in the TypeScript project).

Suggested improvement.

I want to create a small signals library right into the metrics package. This would allow devs to update the status of a mutant, resulting in cascading changes in the entire model (so file metrics and parent directory metrics). Next, we could wire up these signals into the "reactive" base class we are currently using, drawing inspirations from @lit-labs/preact-signals.

The result is that changes to the model automatically cascade to the screen, no need for the custom update code we use now.

I want to implement this as a breaking change to keep things simpler.

Alternatives I've considered

  • We could create a custom solution inside metrics like this, and keep the rest of the API the same:
    const report = new MutationTestingReport(reportsJson);
    // report.results etc work as they do now.
    report.updateMutant(mutant);
    // report.results etc updated  
    However, more is needed to solve the more significant issue of what to update on the screen.
  • We could try to depend on @lit-labs/preact-signals directly from metrics and use that library. However, this would add a dependency to metrics, which also adds that dependency to all dependents, like the dashboard and StrykerJS. Also, if lit-labs ever decided on a different Signals API, it would mean further breaking changes. As stated in their blog, they landed on preact-signals with little consideration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions