Skip to content

feat: properly resolve async rendered DOM when taking element screenshot and add storybook 8 support - #70

Merged
sunilsurana merged 4 commits into
microsoft:storybook7from
Hotell:fix-support-story-store-v7
Feb 11, 2025
Merged

feat: properly resolve async rendered DOM when taking element screenshot and add storybook 8 support#70
sunilsurana merged 4 commits into
microsoft:storybook7from
Hotell:fix-support-story-store-v7

Conversation

@Hotell

@Hotell Hotell commented Feb 11, 2025

Copy link
Copy Markdown
  • replaces sync selector with async to work in all scenarios
  • adds storybook 8 support

Follows #69

@Hotell Hotell changed the title Fix support story store v7 fix: properly resolve async rendered DOM when taking element screenshot Feb 11, 2025
@Hotell
Hotell force-pushed the fix-support-story-store-v7 branch from 97b64a8 to 4e4c42a Compare February 11, 2025 12:29
@Hotell Hotell changed the title fix: properly resolve async rendered DOM when taking element screenshot feat: properly resolve async rendered DOM when taking element screenshot and add storybook 8 support Feb 11, 2025
Comment thread package.json
"peerDependencies": {
"react": "^18.0.0 || ^17.0.0 || ^16.0.0"
"react": "^18.0.0 || ^17.0.0 || ^16.0.0",
"@storybook/preview-api": ">=7.0.0 <9.0.0"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

explicit API contract against SB version

@Hotell Hotell Feb 11, 2025

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

💡 v8 is the official end of life for this package it seems.

In v9, the apis to programatically invoke storyFn() will no longer exist

only exposed APIs to obtain stories starting v9:

https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#storystore-and-methods-deprecated

const stories = await window.__STORYBOOK_PREVIEW__.extract();

which returns Object of parsed CSF.

  • there is no storyFn()
  • there is render(), which cannot be used as that's referring the component implementation which needs passing props and refs if used

possible implementation to support v9

  • change the APIs to be defined via parameters which would need to be serializable in order to properly reflect these Steps values within the created CSF story object

/**
* Stories are loaded via native ESM (async), we need to wait for the JS to be loaded and applied on DOM
*/
const element = await this.page.waitForSelector(selector);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

handles async code as expected ( when storyStoreV7 is enabled)

@Hotell
Hotell marked this pull request as ready for review February 11, 2025 15:13
@sunilsurana
sunilsurana merged commit ddc3985 into microsoft:storybook7 Feb 11, 2025
// storyStoreV7:
// - is configurable only in SB v7
// - is `true` by default SB v7
// - doesn't exist in SB v7 (enabled by default)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Suggested change
// - doesn't exist in SB v7 (enabled by default)
// - doesn't exist in SB v8 (enabled by default)

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.

2 participants