Skip to content

Commit

Permalink
Update storybook integration to support v8
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuth committed Mar 5, 2024
1 parent d063a34 commit 92f8df6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- [new] Support Storybook v8

# 7.2.0 (2024-02-12)

- [new] Add `config` parameter, which is passed to `axe.configure` [#88](https://github.com/chanzuckerberg/axe-storybook-testing/pull/88)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This project adheres to the [Contributor Covenant code of conduct](https://www.c
## Minimum requirements

- Node 12
- Storybook 7.0 (for Storybook 6, use axe-storybook-testing v6.3.1)
- Storybook 7.0 or 8.0 (for Storybook 6, use axe-storybook-testing v6.3.1)
- axe-core 4.0

## Installation
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"zod": "^3.22.4"
},
"peerDependencies": {
"@storybook/preview-api": "^7.0.0 || ^8.0.0-rc.1",
"@storybook/preview-api": "^7.0.0 || ^8.0.0",
"axe-core": "^4.0.0"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions src/browser/StorybookPage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type {PreviewWeb} from '@storybook/preview-api';
import type {PreviewWeb, StoryStore} from '@storybook/preview-api';
import type {Renderer, StoryIdentifier, Parameters} from '@storybook/types';
import pTimeout from 'p-timeout';
import type {Page} from 'playwright';
Expand Down Expand Up @@ -72,9 +72,7 @@ function fetchStoriesFromWindow(): Promise<StorybookStory[]> {
);
}

const storyStore = storybookPreview.storyStore;

return storyStore.cacheAllCSFFiles().then(() => {
return storybookPreview.extract().then(() => {
// Pick only the properties we need from Storybook's representation of a story.
//
// This is necessary because Playwright's `page.evaluate` requires return values to be JSON
Expand All @@ -96,6 +94,8 @@ function fetchStoriesFromWindow(): Promise<StorybookStory[]> {
};
}

const storyStore = storybookPreview.storyStore as StoryStore<Renderer>;

return storyStore
.raw()
.map(pickOnlyNecessaryAndSerializableStoryProperties);
Expand Down

0 comments on commit 92f8df6

Please sign in to comment.