-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
π€ 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