Skip to content

Example names are whole paragraphs (or six identical lines); the enclosing heading is usually the better name #123

Description

@aslakhellesoy

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions