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

[Bug]: Storybook v8.5 First Test Fails on Cypress #30347

Open
iamjohnpeet opened this issue Jan 22, 2025 · 4 comments
Open

[Bug]: Storybook v8.5 First Test Fails on Cypress #30347

iamjohnpeet opened this issue Jan 22, 2025 · 4 comments

Comments

@iamjohnpeet
Copy link

iamjohnpeet commented Jan 22, 2025

Describe the bug

When running Storybook v8.5 with Cypress for end-to-end (E2E) tests, the first test always fails, irrespective of the test content. Subsequent tests execute and pass as expected. The failure occurs because the Storybook server does not appear to be running for the first test, displaying a white screen. However, the server is loaded for the second test onward.

Reproduction link

N/A

Reproduction steps

  1. Use the following nx script for running E2E tests:
"targets": {
    "e2e": {
      "executor": "nx:run-commands",
      "options": {
        "command": "start-server-and-test 'nx run shared-react-design-system:storybook' http-get://localhost:4400  'nx run shared-react-design-system-e2e:e2e:cypress'"
      }
    },
    "e2e:cypress": {
      "executor": "@nx/cypress:cypress",
      "options": {
        "cypressConfig": "libs/shared/react/design-system-e2e/cypress.config.ts",
        "testingType": "e2e"
      },
      "configurations": {
        "ci": {
          "devServerTarget": "shared-react-design-system:storybook:ci"
        }
      }
    }
  }
  1. Run the e2e target.
    3a. The first test fails, displaying a white screen when running from localhost on port 4400.
    3b. Logged errors:
    CypressError:cy.visit() failed trying to load:
    We attempted to make an http request to this URL but the request failed without a response.
    Error: ESOCKETTIMEDOUT
  2. The subsequent tests complete successfully.

System

macOS: "15.0.1"
nx: "20.2.2"
cypress: "13.17.0"

Additional context

This still occurs when the first test is removed and the next available test is bumped up to run first.

Updating just the storybook package to v8.5 is fine, this issues occurs when updating the storybook addon packages to:

   "@storybook/addon-a11y": "8.5.0",
    "@storybook/addon-essentials": "8.5.0",
    "@storybook/core-server": "8.5.0",
    "@storybook/nextjs": "8.5.0",
    "@storybook/react": "8.5.0",
@shilman
Copy link
Member

shilman commented Jan 24, 2025

Are you upgrading from a previous working version? Or is this a fresh install?

Are you waiting for the server to be ready using wait-on or something similar?

@iamjohnpeet
Copy link
Author

iamjohnpeet commented Jan 24, 2025

Upgrading from 8.4.7
Using start-server-and-test to start the server, so should have gotten a 200 response from the server before continuing I believe.

@shilman
Copy link
Member

shilman commented Jan 24, 2025

Was it working as expected in 8.4.7 and now failing in 8.5.x?

@iamjohnpeet
Copy link
Author

Yeah ran fine with 8.4.7.
We simply visit the playground page and check accessibility has no errors with Cypress.

beforeEach(() => {
    cy.visit('/?path=/story/accordion--playground');
    cy.resetControls();
  });

  afterEach(() => {
    cy.checkAccessibility();
  });

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

No branches or pull requests

2 participants