deriveExampleName takes the example's first paragraph, which is also what the vitest reporter shows as the test name. With prose-style oaths that produces names like this:
✓ A visitor wants all of it. The visitor reserves the whole of "Moose in Sunset" and checks
out the basket. Because a whole artwork is bought in one payment of its own, they are sent
to 1 checkout, and the checkout lists:
and, when an example opens with a data table, like this — the entire suite, before I rewrote it:
✓ |varar| src/features/process_order.md (6 tests)
✓ Given the following people have accounts:
✓ Given the following people have accounts:
✓ Given the following people have accounts:
✓ Given the following people have accounts:
✓ Given the following people have accounts:
Both ends of the range are bad, and they fail differently: the first is unreadable because it is 200 characters of prose, the second because six examples share one name and the runner output tells you nothing about which failed.
Meanwhile the heading directly above each example usually says exactly what it is:
## A buyer who never confirms their identity is refunded
## A buyer who confirms in time gets everything
## A buyer verified beforehand is not made to wait
That is the list I want to see in a test report, and it is already in the document.
Suggestion
Name an example after its nearest enclosing heading, falling back to the first paragraph when there isn't one, and disambiguating when a heading covers several examples (## Heading, ## Heading (2), or appending the first matched sentence).
The trade-off I can see: varar.lock.json identifies baseline examples by name and re-identifies them by word-similarity across edits, so changing the naming scheme changes drift's matching behaviour, and renaming a heading would look like a bigger change than it is. Possibly the reported name and the baseline identity want to be two different things — the lock keeps the paragraph text it has now, while reports use the heading.
Related: #109 (whether a report shows that steps were spliced in from another oath) is the same question of "what should a report show", and the answers probably want to be consistent.
deriveExampleNametakes the example's first paragraph, which is also what the vitest reporter shows as the test name. With prose-style oaths that produces names like this:and, when an example opens with a data table, like this — the entire suite, before I rewrote it:
Both ends of the range are bad, and they fail differently: the first is unreadable because it is 200 characters of prose, the second because six examples share one name and the runner output tells you nothing about which failed.
Meanwhile the heading directly above each example usually says exactly what it is:
That is the list I want to see in a test report, and it is already in the document.
Suggestion
Name an example after its nearest enclosing heading, falling back to the first paragraph when there isn't one, and disambiguating when a heading covers several examples (
## Heading,## Heading (2), or appending the first matched sentence).The trade-off I can see:
varar.lock.jsonidentifies baseline examples by name and re-identifies them by word-similarity across edits, so changing the naming scheme changes drift's matching behaviour, and renaming a heading would look like a bigger change than it is. Possibly the reported name and the baseline identity want to be two different things — the lock keeps the paragraph text it has now, while reports use the heading.Related: #109 (whether a report shows that steps were spliced in from another oath) is the same question of "what should a report show", and the answers probably want to be consistent.