Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Storybook static build tests #54

Open
kettanaito opened this issue Mar 22, 2021 · 2 comments
Open

Add Storybook static build tests #54

kettanaito opened this issue Mar 22, 2021 · 2 comments

Comments

@kettanaito
Copy link
Member

kettanaito commented Mar 22, 2021

Context

In our current Storybook integration example we feature in-browser tests against the running Storybook.

What

We need to add tests for the static Storybook build (as after running the yarn build-storybook command). We will take the static build, open it locally (via Puppeteer since we're already using it in the example), and test two scenarios:

Our current component only features the useFetch hooks that calls fetch underneath. We'd have to create another component that does a request via XMLHttpRequest, create a story for it, and cover it with tests.

Steps

  1. Create a new React component the same as the current GitHubUser component. In the new component, use XMLHttpRequest to make a request, remove the useFetch hook, and the logic around it.
  2. Create a new story for the newly created React component. Put it in the stories/[ComponentName].stories.js.
  3. Create a new E2E test in the e2e/[ComponentName].e2e.test.js. In this test use Puppeteer to load the locally build Storybook project, navigate to the story, and assert that it renders the elements based on the mocked data.
@dandelionadia
Copy link

I would like to try to do it.

@kettanaito
Copy link
Member Author

@dandelionadia, that'd be awesome! Let me know if you have any questions.

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

No branches or pull requests

2 participants