Feature Request]: "Behavior" (BDD) rendering mode for the Interactions panel. #35511
paul-hammant
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Is your feature request related to a problem? Please describe.
The Interactions panel renders the instrumenter call stream in implementation voice — literal calls with resolved arguments. Two consequences:
It documents how the test is written, not what the component promises, so a story
catalogue can't double as a living spec for anyone who doesn't read testing-library.
Printing resolved values loses the subject. A real example from our catalogue
(a table's
Loadingstory):That second line was
expect(canvas.queryByText('John Doe')).toBeNull()— the onefact a reader needs ("John Doe is not shown while loading") is exactly the part
that evaporated.
Everything needed to fix this already exists: the instrumenter events carry method,
path refs, args, and pass/fail status; story metadata carries the title path and story
name. The gap is purely presentational.
Describe the solution you'd like
An optional rendering mode on the Interactions panel (toggle or parameter) that
renders the same event stream as behavior sentences:
describe/(leaf = component)userEvent.*/fireEvent.*calls<subject>should …expectmatcher calls, matcher name humanized (toHaveClass→ "should have class")Locator calls (
within,getBy*,queryBy*,findBy*) and bareexpect(target)calls are suppressed from the log but mined for the subject (e.g. the string arg of
getByLabelText('Admin')), threaded onto the matcher line. The two lines above become:and an interaction test reads:
Doing this inside Storybook is strictly better than userland: the instrumenter still
has expression context at record time, whereas an external consumer must reconstruct
subjects from
__callId__refs and irrecoverably loses them whenever a query resolvesto
nullor a primitive (theexpect(null)case above).Describe alternatives you've considered
preparehook that subscribes tostorybook/instrumenter/calland renders a liveBDD log into the preview during headed test-runner passes (~200 lines). It works,
but it couples to undocumented channel internals, has the null-subject limitation
above, and we deliberately don't ship it to
storybook buildoutput — which isexactly where non-developer readers are.
panel's step-through affordances.
Are you able to assist to bring the feature to reality?
yes, I can
Additional context
Observed with Storybook 10.3.6 (
@storybook/react-webpack5),@storybook/test-runner0.24.4, instrumenter active (
instrument=true). The value proposition in one line:the Interactions panel currently answers "what did the test do?"; a behavior mode
would answer "what does the component promise?" — turning every story catalogue into
living documentation for free.
All reactions