Skip to content

ESLint: Recognize storybook/test imports in await-interactions - #35460

Merged
valentinpalkovic merged 5 commits into
storybookjs:nextfrom
TemRevil:fix/await-interactions-storybook-test
Oct 27, 2026
Merged

valentinpalkovic merged 5 commits into
storybookjs:nextfrom
TemRevil:fix/await-interactions-storybook-test

Conversation

@TemRevil

@TemRevil TemRevil commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Closes #35456

What I did

eslint-plugin-storybook's await-interactions rule only fired when userEvent/expect were imported from @storybook/testing-library, @storybook/jest, or @storybook/test. Storybook v10 exposes these from the bare storybook/test entry point, so play functions importing from storybook/test were never linted.

Added storybook/test to both isUserEventFromStorybookImported and isExpectFromStorybookImported, so v10 imports are treated exactly like @storybook/test, plus an invalid test case covering the new import path.

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

  1. In the eslint-plugin package, add a story/play function that imports userEvent/expect from storybook/test (not @storybook/test) and calls userEvent.click(...) or expect(...).toHaveBeenCalled() without await.
  2. Run the plugin's await-interactions rule against that file (e.g. via the rule's own RuleTester, or eslint configured with plugin:storybook/recommended against a .storybook project using v10's storybook/test import).
  3. On next (before this fix) the un-awaited call is not flagged. With this change it is flagged the same way an un-awaited @storybook/test import already is.

I verified the rule logic directly with ESLint's Linter API: a storybook/test import produces the two expected interactionShouldBeAwaited errors, @storybook/test still produces one, and an unrelated chai import produces none. I couldn't run the eslint-plugin's own vitest suite in an isolated container (the monorepo's TS/build tooling doesn't install standalone), so CI's eslint-plugin test job is the authoritative check for the added test case.

Documentation

  • Add or update documentation reflecting your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Checklist for Maintainers

  • When this PR is ready for testing, make sure to add ci:normal, ci:merged or ci:daily GH label to it to run a specific set of sandboxes.
  • Declare whether manual QA will be needed for this PR during the next release, through qa:needed or qa:skip
  • Make sure this PR contains one of the bug/maintenance/dependencies/build/cleanup/documentation/feature request/BREAKING CHANGE/other labels

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection of Storybook interactions imported from supported test entry points.
    • The linting rule now correctly flags missing await usage for expect, findByText, and related interactions.
    • Fix suggestions now add await where required.

…port

The await-interactions rule only recognised userEvent/expect imported
from @storybook/testing-library, @storybook/jest and @storybook/test.
Storybook v10 exposes these from the bare storybook/test entry point,
so play functions importing from there were never linted.

Add storybook/test to both import checks and cover it with a test case.
@coderabbitai

coderabbitai Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: baa2f7b3-b20b-4fc8-b310-4cf3b57e92d6

📥 Commits

Reviewing files that changed from the base of the PR and between 919c26e and f45880f.

📒 Files selected for processing (1)
  • code/lib/eslint-plugin/src/rules/await-interactions.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • code/lib/eslint-plugin/src/rules/await-interactions.test.ts

📝 Walkthrough

Walkthrough

The await-interactions rule recognizes expect and userEvent imports from @storybook/test and storybook/test. A test confirms missing await suggestions for expect(...).toHaveBeenCalled() and findByText(...).

Changes

Storybook test import support

Layer / File(s) Summary
Import detection and validation
code/lib/eslint-plugin/src/rules/await-interactions.ts, code/lib/eslint-plugin/src/rules/await-interactions.test.ts
The rule accepts additional Storybook test module specifiers, with coverage verifying await suggestions for synchronous and asynchronous interactions.

Estimated code review effort: 2 (Simple) | ~10 minutes


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@code/lib/eslint-plugin/src/rules/await-interactions.test.ts`:
- Around line 201-222: Add the expected suggestions arrays to both error entries
in the new storybook/test case within the await-interactions rule tests,
matching the suggestion structure and replacement text used by comparable cases
for toHaveBeenCalled and findByText.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b605ab8d-d1fd-4946-b910-dda737490ca5

📥 Commits

Reviewing files that changed from the base of the PR and between 9e6cad3 and 919c26e.

📒 Files selected for processing (2)
  • code/lib/eslint-plugin/src/rules/await-interactions.test.ts
  • code/lib/eslint-plugin/src/rules/await-interactions.ts

@TemRevil TemRevil changed the title fix(eslint-plugin): apply await-interactions to the storybook/test import ESLint: Recognize storybook/test imports in await-interactions Jul 11, 2026
@bodograumann

Copy link
Copy Markdown
Contributor

This seems pretty straight-forward to me, @valentinpalkovic . Can we merge?

@TemRevil

TemRevil commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Appreciate you jumping in here, hope valentinpalkovic gets a chance to take another look soon.

@valentinpalkovic valentinpalkovic self-assigned this Aug 8, 2026
@valentinpalkovic valentinpalkovic moved this to In Progress in Core Team Projects Aug 8, 2026
@storybook-contribution-review storybook-contribution-review Bot added sev:S4 Low priority. Wait for community PRs. and removed sev:S3 Medium priority. Fix within months if possible. labels Sep 11, 2026
@valentinpalkovic valentinpalkovic added the ci:normal Run our default set of CI jobs (choose this for most PRs). label Oct 16, 2026

@storybook-contribution-review storybook-contribution-review Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 I am the Storybook contribution review bot. This message was posted automatically. A human maintainer makes the final decision on this PR.
Review phase: Runtime verification (stage 3 of 3)

We are trying a three-stage automated review: architecture, code quality, and runtime verification. This message states which stages ran and which were skipped. Messages are posted automatically, and a human maintainer makes the final decision. Please tell us whether the feedback and evidence are useful.

Thanks for picking up #35456, @TemRevil! This review covers head f45880f. All three stages ran and passed, and none were skipped. There are no blocking findings.

  • Architecture: passed.
  • Code quality: passed. The type check passes, and the await-interactions suite passes 23/23.
  • Runtime verification: passed. We ran real ESLint 8.57.1 on a story file shaped like the repro in #35456 (import { expect, userEvent, fn } from "storybook/test"). The base commit reports 0 errors. This head reports both un-awaited calls. Each changed check (userEvent and expect from storybook/test) fails on base and passes on head when tested alone. Imports from @storybook/test, @storybook/jest and @storybook/testing-library behave the same as before.

The inline comments are optional suggestions plus one note about older behavior. None of them blocks this PR.

One small request: please paste the terminal output from running the rule's tests on your branch, for example yarn vitest run src/rules/await-interactions.test.ts from code/lib/eslint-plugin. We ask every first-time contributor for this, and I've added verification:pending until it's here.

@storybook-contribution-review storybook-contribution-review Bot added review:verified Three-step review passed: architecture, code quality, runtime verification verification:pending labels Oct 16, 2026
@storybook-contribution-review storybook-contribution-review Bot moved this from In Progress to Human verification in Core Team Projects Oct 16, 2026
@storybook-contribution-review

Copy link
Copy Markdown
Contributor

🤖 I am the Storybook contribution review bot. This message was posted automatically. A human maintainer makes the final decision on this PR.
Review phase: Thermo-nuclear code quality review (stage 2 of 3)

We are trying a three-stage automated review: architecture, code quality, and runtime verification. This message states which stages ran and which were skipped. Messages are posted automatically, and a human maintainer makes the final decision. Please tell us whether the feedback and evidence are useful.

Thanks again for this fix, @TemRevil! After next was merged into this branch (head 4e0cff34), the fixed rule started doing its job on the repo's own stories, and that turns the eslint CI job red. One small change is needed before this can merge.

Requested change (blocking): code/core/template/stories/argTypes.stories.ts imports expect from storybook/test and has 3 matcher calls without await. This rule now reports them correctly, so the eslint job fails on this PR (it passes on the base commit). Please add await to these 3 calls in this PR:

  • line 56: await expect(argTypes.a).toBeUndefined();
  • line 76: await expect('argTypes' in context).toBe(false);
  • line 77: await expect(() => context.argTypes).toThrow(/no longer part of the story context/);

Both play functions are already async, and the same file already awaits toMatchObject, so nothing else needs to change. Please don't add a disable comment: the rule is right here. I'm putting this in a top-level comment because the file isn't part of this PR's diff, so there is no line to attach an inline comment to.

Stages: architecture (stage 1) carries forward, because the merge didn't change this PR's own patch. Code quality (stage 2) asks for the change above. Runtime verification (stage 3) has not run on this head yet; it will run again after the fix. My earlier optional suggestions still apply and don't block.

@storybook-contribution-review storybook-contribution-review Bot removed the review:verified Three-step review passed: architecture, code quality, runtime verification label Oct 16, 2026
@storybook-contribution-review storybook-contribution-review Bot added the review:changes-requested Review paused: changes requested; the review comment names the failing stage label Oct 16, 2026
@valentinpalkovic valentinpalkovic removed their assignment Oct 20, 2026
@valentinpalkovic

Copy link
Copy Markdown
Contributor

Hi @TemRevil

Thank you for your contribution so far! Would you like to resolve the mentioned ci/circleci: eslint issue?

@TemRevil

Copy link
Copy Markdown
Contributor Author

Fixed in 455b50a. With the rule now recognising storybook/test imports, it flags three un-awaited expect calls in core/template/stories/argTypes.stories.ts. I added the awaits. Danger and the Chromatic storybook-ui check also failed on the last run, so I will check those once CI reruns.

@storybook-app-bot

storybook-app-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Package Benchmarks

Commit: 455b50a, ran on 20 October 2026 at 22:45:41 UTC

The following packages have significant changes to their size or dependencies:

storybook

Before After Difference
Dependency count 62 68 🚨 +6 🚨
Self size 18.93 MB 21.98 MB 🚨 +3.04 MB 🚨
Dependency size 25.95 MB 27.06 MB 🚨 +1.11 MB 🚨
Bundle Size Analyzer Link Link

@storybook/svelte-vite

Before After Difference
Dependency count 12 12 0
Self size 56 KB 56 KB 🎉 -443 B 🎉
Dependency size 30.75 MB 30.73 MB 🎉 -13 KB 🎉
Bundle Size Analyzer Link Link

@storybook/sveltekit

Before After Difference
Dependency count 13 13 0
Self size 59 KB 58 KB 🎉 -1 KB 🎉
Dependency size 30.80 MB 30.79 MB 🎉 -14 KB 🎉
Bundle Size Analyzer Link Link

@storybook/vue3-vite

Before After Difference
Dependency count 95 95 0
Self size 32 KB 32 KB 🎉 -34 B 🎉
Dependency size 18.76 MB 18.78 MB 🚨 +21 KB 🚨
Bundle Size Analyzer Link Link

@storybook/web-components-vite

Before After Difference
Dependency count 14 6 🎉 -8 🎉
Self size 19 KB 19 KB 🚨 +12 B 🚨
Dependency size 25.50 MB 531 KB 🎉 -24.97 MB 🎉
Bundle Size Analyzer Link Link

@storybook/cli

Before After Difference
Dependency count 174 174 0
Self size 891 KB 883 KB 🎉 -7 KB 🎉
Dependency size 81.25 MB 83.25 MB 🚨 +2.00 MB 🚨
Bundle Size Analyzer Link Link

@storybook/codemod

Before After Difference
Dependency count 167 167 0
Self size 42 KB 44 KB 🚨 +3 KB 🚨
Dependency size 79.74 MB 81.73 MB 🚨 +1.99 MB 🚨
Bundle Size Analyzer Link Link

create-storybook

Before After Difference
Dependency count 63 69 🚨 +6 🚨
Self size 1.07 MB 1.07 MB 🚨 +5 KB 🚨
Dependency size 44.88 MB 49.04 MB 🚨 +4.15 MB 🚨
Bundle Size Analyzer node node

@storybook/svelte

Before After Difference
Dependency count 4 4 0
Self size 264 KB 253 KB 🎉 -11 KB 🎉
Dependency size 4.85 MB 4.85 MB 🎉 -10 B 🎉
Bundle Size Analyzer Link Link

@storybook/vue3

Before After Difference
Dependency count 91 91 0
Self size 209 KB 232 KB 🚨 +23 KB 🚨
Dependency size 18.22 MB 18.22 MB 🎉 -10 B 🎉
Bundle Size Analyzer Link Link

@storybook/web-components

Before After Difference
Dependency count 12 4 🎉 -8 🎉
Self size 192 KB 196 KB 🚨 +3 KB 🚨
Dependency size 25.10 MB 126 KB 🎉 -24.97 MB 🎉
Bundle Size Analyzer Link Link

@storybook-contribution-review

Copy link
Copy Markdown
Contributor

🤖 I am the Storybook contribution review bot. This message was posted automatically. A human maintainer makes the final decision on this PR.
Review phase: Runtime verification (stage 3 of 3)

We are trying a three-stage automated review: architecture, code quality, and runtime verification. This message states which stages ran and which were skipped. Messages are posted automatically, and a human maintainer makes the final decision. Please tell us whether the feedback and evidence are useful.

Thanks for the quick fix, @TemRevil! The three awaits in code/core/template/stories/argTypes.stories.ts resolve the lint finding from our last review, and all three review stages now pass on head 455b50a6:

  • Architecture (stage 1): pass, carried forward. This push doesn't touch the rule or package layout.
  • Code quality (stage 2): pass. The new awaits sit in play functions that were already async, so control flow is unchanged.
  • Runtime verification (stage 3): pass, re-run on this head:
    • With real ESLint, the [Bug]: eslint-plugin-storybook rule await-interactions not compatible with @storybook/test #35456 repro (userEvent + expect from storybook/test) reports 0 on base and 2 on head. userEvent alone and expect alone each go from 0 to 1. The legacy @storybook/test, @storybook/jest and @storybook/testing-library sources give the same output on base and head.
    • The new test case fails against the base rule and passes on head. The rule suite passes 23/23 and the eslint-plugin package passes 166/166.
    • The repo's own oxlint reports 3 await-interactions errors on argTypes.stories.ts before your fix and 0 after it, with no errors across code/.

Not checked by us: the Chromatic storybook-ui visual diff and the Danger qa:* / team-approval requirements are for maintainers to handle. Adding await to assertions can't change what renders. The pre-existing "last import wins" behavior noted earlier is unchanged and out of scope here.

The earlier request for your own test or terminal output still applies, so verification:pending stays on the PR.

@storybook-contribution-review storybook-contribution-review Bot added review:verified Three-step review passed: architecture, code quality, runtime verification and removed review:changes-requested Review paused: changes requested; the review comment names the failing stage labels Oct 20, 2026
@valentinpalkovic valentinpalkovic removed the ci:normal Run our default set of CI jobs (choose this for most PRs). label Oct 27, 2026
@valentinpalkovic valentinpalkovic added ci:focus Run the focused single-job CI workflow. and removed needs triage labels Oct 27, 2026
@valentinpalkovic valentinpalkovic self-assigned this Oct 27, 2026
@valentinpalkovic valentinpalkovic added the qa:skip Pull Requests that do not need any QA. (e.g. documentation) label Oct 27, 2026
@valentinpalkovic
valentinpalkovic merged commit afd3107 into storybookjs:next Oct 27, 2026
29 of 39 checks passed
@github-project-automation github-project-automation Bot moved this from Human verification to Done in Core Team Projects Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-scan:automated bug ci:focus Run the focused single-job CI workflow. qa:skip Pull Requests that do not need any QA. (e.g. documentation) review:verified Three-step review passed: architecture, code quality, runtime verification sev:S4 Low priority. Wait for community PRs. verification:pending

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: eslint-plugin-storybook rule await-interactions not compatible with @storybook/test

3 participants