Skip to content

Proposal: option for UsageFormatter to enable deterministic outputΒ #2439

@badeball

Description

@badeball

πŸ€” What's the problem you're trying to solve?

I have a slight problem testing the messages implementation of the non-associated Cypress implementation that I develop and maintain. Due to the chaotic and messy nature of Cypress plugin development, almost every test is an e2e test which invokes Cypress and verify some effect. For messages, this entails invoking the usage, json and html formatter and asserting their output, as seen eg. here.

The UsageFormatter sorts lines and its output based on execution time of steps.

For these test to be deterministic, I have to patch the usage formatter (or rather one of its helper methods), as seen here. I have no way of injecting a mock implementation of a clock, like done in the usage formatter's unit tests.

Unfortunately, patching dependencies using a typical postinstall script during local development and not have it invoked by consumers of the library, is less than trivial with npm, let alone all other package managers, as can be seen here.

✨ What's your proposed solution?

I'm wondering what you think about adding an option (possibly internal) to the UsageFormatter, to make its output deterministic (in regards to sorting lines). I would write the implementation and tests. What do you think?

⛏ Have you considered any alternatives or workarounds?

I could add actual and suffuciently large interrupts in each step, in order to be sure of the actual outcome, but I avoid that like the plague and I have yet to resort to such.

πŸ“š Any additional context?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    βœ… acceptedThe core team has agreed that it is a good idea to fix this⚑ enhancementRequest for new functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions