Skip to content

Conversation

chr33s
Copy link
Contributor

@chr33s chr33s commented Jun 6, 2025

closes: #30944

@chr33s
Copy link
Contributor Author

chr33s commented Jun 6, 2025

@JohnAlbin that time of year again, this adds storybook 9 support, it introduces backwards incompatible changes so best to update readme & bump version.

@chr33s chr33s force-pushed the main branch 4 times, most recently from dd06071 to 57ddfdf Compare June 6, 2025 07:54
@chr33s
Copy link
Contributor Author

chr33s commented Jun 6, 2025

sorry for GitHub actions noise. I updated the dependencies as well in https://github.com/chr33s/storybook-addon-fetch-mock/tree/update . Opted to keep it separate to not pollute this pr's purpose.

@chr33s chr33s deleted the branch JohnAlbin:main June 30, 2025 05:21
@chr33s chr33s closed this Jun 30, 2025
@chr33s chr33s deleted the main branch June 30, 2025 05:21
@chr33s chr33s restored the main branch June 30, 2025 05:22
@chr33s chr33s reopened this Jun 30, 2025
@chr33s chr33s deleted the branch JohnAlbin:main June 30, 2025 05:26
@chr33s chr33s closed this Jun 30, 2025
@chr33s chr33s deleted the main branch June 30, 2025 05:26
@chr33s chr33s restored the main branch June 30, 2025 05:26
@chr33s chr33s reopened this Jun 30, 2025
@Copilot Copilot AI review requested due to automatic review settings August 25, 2025 06:39
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the storybook-addon-fetch-mock library to support Storybook 9, involving significant API changes and modernization of the codebase.

  • Updates fetch-mock API calls to use new v12 syntax (route() instead of mock(), hardReset() instead of reset())
  • Migrates from legacy Storybook imports to new v9 internal module structure
  • Modernizes build tooling with Vite configuration and ESLint flat config

Reviewed Changes

Copilot reviewed 11 out of 14 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
package.json Updates dependencies to Storybook 9 and fetch-mock 12, changes package name and repository
src/withFetchMock.ts Updates fetch-mock API calls and import paths for Storybook 9 compatibility
src/preview.ts Updates Storybook type imports to use internal module paths
eslint.config.js Migrates from legacy .eslintrc.cjs to modern flat config format
.storybook/main.ts Adds Storybook configuration for testing the addon
tests/ Adds test components and stories to verify addon functionality
vite.config.ts Adds Vite configuration for modern build tooling

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +50 to +51
fetchMock.callHistory.calls().forEach((call) => {
calls[call.url] = call;
Copy link
Preview

Copilot AI Aug 25, 2025

Choose a reason for hiding this comment

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

Using call.url as the object key could cause collisions if multiple calls are made to the same URL. The original code used call.identifier which would be unique. Consider using a combination of URL and index or timestamp to ensure uniqueness.

Suggested change
fetchMock.callHistory.calls().forEach((call) => {
calls[call.url] = call;
fetchMock.callHistory.calls().forEach((call, i) => {
const key = call.identifier ? call.identifier : `${call.url}-${i}`;
calls[key] = call;

Copilot uses AI. Check for mistakes.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@shooftie
Copy link

I fully sympathise with the situation that the @JohnAlbin finds himself in and so am asking this as gently as possible; @chr33s, do you have any idea when this might be merged? I've just upgraded to v9 and this has become the proverbial "fly in the ointment".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Storybook 9] Addon compatibility - Update needed
2 participants