ava
ava copied to clipboard
Truncating titles
I often find myself formatting generated long test and macro titles to shorter strings (I never felt the need to do this for assertion titles, as I rarely use them). I do this to avoid littering AVA's output. See for instance here where I truncate large integer string representations or here where I did not truncate the title string by lack of motivation to implement yet another custom truncation function.
I thought it would make sense to have some sensible default tagged template literal function to nicelly format these. I think it can easily be implemented independently from AVA (requiring to manually tag each title template literal). Do you think it would make sense to include such a solution as part of the ava package?
I do not think such a transformation should be applied by default to all titles, since, as I understand it, titles are used as test unique keys. Now only the printed title could be altered but in case of an error there would be no way to visually distinguish between two tests whose distinct titles get formatted to the same printed string. Although a solution in that case would be to dump the unique title without formatting.
Do you think it would make sense to include such a solution as part of the
avapackage?
I'd imagine this to be specific to each project and hard to generalize?
Now only the printed title could be altered but in case of an error there would be no way to visually distinguish between two tests whose distinct titles get formatted to the same printed string.
A better reporter would know that all tests in a file passed, and could then truncate based on terminal width, and if there are failures, make sure the truncation is unambiguous. But we first need to improve our reporter 😄