percy / percy-storybook

Percy's Storybook SDK.
https://docs.percy.io/docs/storybook
MIT License
149 stars 45 forks source link

When upgrading to Storybook 8 I get "Error: Storybook object not found on the window. Open Storybook and check the console for errors." #911

Closed rudeayelo closed 1 month ago

rudeayelo commented 6 months ago

The problem

When I try tu upgrade to the latest version of Storybook (8.0.4 currently) and I trigger the percy storybook command, the process stops just after downloading Chromium.

Environment

Details

If necessary, describe the problem you have been experiencing in more detail.

Debug logs

[percy] Successfully downloaded Chromium 929475
[percy] Percy has started!
[percy] Stopping percy...
[percy] Build not created
[percy] Error: Storybook object not found on the window. Open Storybook and check the console for errors.
error: script "test-storybook:visual" exited with code 1

Code to reproduce issue

I grabbed the React starter template from Storybook, upgraded it and added Percy, same issue appears, here's the repo: https://github.com/rudeayelo/percy-storybook-8

ArnaudWeyts commented 6 months ago

Also running into this, but it seems like it's flaky for me. Sometimes it passes, sometimes it throws this error.

JackHowa commented 6 months ago

Experienced this too. It sometimes works?

jalandis commented 5 months ago

Just ran into this issue while upgrading to Storybook 8.

[percy:cli] Error: Storybook object not found on the window. Open Storybook and check the console for errors.
dkremez commented 5 months ago

We are running into the same issue.

[percy] Error: Storybook object not found on the window. Open Storybook and check the console for errors.
error Command failed with exit code 1.
rudeayelo commented 5 months ago

I reported it through BrowserStack support center, as suggested here: https://github.com/percy/percy-storybook/pull/918#issuecomment-2027162812

MaelFr commented 4 months ago

Hello, Received some news regarding this issue:

The Engineering team … informed me that they have prioritized this task and begun working on the Storybook upgrade for v8. We anticipate completing this upgrade by the 20th of May (Tentative).

rishigupta1599 commented 4 months ago

Hey, A quick update here. We have shipped percy/storybook v6.0.0-beta.0 SDK which should resolve this issue.

Do try out the new SDK, and provide us feedback. Maybe even close this issue, if the problem has been resolved. (otherwise, we'll do so if it's not reproducible till the stable version is released)

Thanks.

jacobrask commented 4 months ago

When upgrading to 6.0.0-beta we got a large number of “Error fetching index.json” errors

IMG_0590

etarhan commented 3 months ago

I have the same issue with Error fetching index.json and other asset preloading errors, it seems related to the new package version. I already have a support ticket open with BrowserStack.

As a workaround, the following settings seem to do the trick:

discovery:
  concurrency: 1
  disableCache: true
ppulwey commented 3 months ago

Hey,

any progress with this issue? We have a blocker in our GitLab CI/CD pipeline bc of this.

Amit3200 commented 3 months ago

Hi @ppulwey We are looking into it. Allow us sometime to debug and comeback on it.

rishigupta1599 commented 3 months ago

Hello everyone,

If you could kindly provide us with the reproducible steps of the issue you're experiencing, it would greatly assist us in resolving it efficiently.

Additionally, please reach out to BrowserStack support with the reproducible steps to recreate the issue, preferably using storybook you are using. This will enable us to better understand and address the problem. We're more than happy to assist you further once we have all the necessary information.

In parallel we are trying to reproduce it on our end.

Thank you for your cooperation.

ppulwey commented 3 months ago

Hello everyone,

If you could kindly provide us with the reproducible steps of the issue you're experiencing, it would greatly assist us in resolving it efficiently.

Additionally, please reach out to BrowserStack support with the reproducible steps to recreate the issue, preferably using storybook you are using. This will enable us to better understand and address the problem. We're more than happy to assist you further once we have all the necessary information.

In parallel we are trying to reproduce it on our end.

Thank you for your cooperation.

Hello @rishigupta1599,

you might have missed that the OP already added a link to a test repo. We're facing this issue in our GitLab CI/CD pipeline with the following configuration in the yml file:

visual_regression_test:
  stage: test
  image:
    name: docker-prod.hv.devk.de/awsplattform/vendor-images/docker.io/library/node:18.16.0-alpine3.17
    entrypoint: [""]
    pull_policy: if-not-present
  tags:
    - cloud-vprod
  variables:
    PERCY_TOKEN:  ${Percy_Token}
    PERCY_TARGET: storybook-static
    PERCY_BROWSER_EXECUTABLE: /usr/bin/chromium-browser
  before_script:
    - apk update && apk add --no-cache chromium
  script:
    - which chromium || which chromium-browser
    - ls storybook-static
    - npm ci
    - npm run test:percy
  needs: ["build_storybook"]
  dependencies:
    - build_storybook

Tried it locally with node 18 and it works. On our side this only occurs in GitLab.

github-actions[bot] commented 2 months ago

This issue is stale because it has been open for more than 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.

ppulwey commented 2 months ago

It's been 20 days and still no progress. Issue is stale now. It's still relevant.

Do you need any further information about this issue. For me it seems you have everything you need.

rishigupta1599 commented 2 months ago

Hey @ppulwey,

After testing on our end with the provided Storybook setup at rudeayelo/percy-storybook-8, we were unable to reproduce any issues with newer SDK version 6.0.0. Our tests ran successfully from local environments, GitHub Actions, and GitLab CI using the same configuration details you shared.

Here are the configurations we used:

GitHub Action Config:

name: Test Storybook

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  test_storybook:
    runs-on: ubuntu-latest

    container:
      image: node:18.16.0-alpine3.17
      options: --entrypoint ""

    env:
      PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
      PERCY_TARGET: storybook-static
      PERCY_BROWSER_EXECUTABLE: /usr/bin/chromium-browser

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Install Chromium
        run: |
          apk update
          apk add --no-cache chromium

      - name: Verify Chromium installation
        run: |
          which chromium || which chromium-browser

      - name: Install dependencies
        run: npm install

      - name: Build Storybook
        run: npm run build-storybook

      - name: Run visual tests
        run: npm run visual
image

GitLab Runner Config:

visual_regression_test:
  stage: test
  image:
    name: node:18.16.0-alpine3.17
    entrypoint: [""]
  variables:
    PERCY_TOKEN: ${Percy_Token}
    PERCY_TARGET: storybook-static
    PERCY_BROWSER_EXECUTABLE: /usr/bin/chromium-browser
  before_script:
    - apk update && apk add --no-cache chromium
  script:
    - which chromium || which chromium-browser
    - ls storybook-static
    - npm install
    - npm run visual

Screenshot 2024-07-08 at 13-01-59 visual_regression_test (#7283735689) · Jobs · Rishi gupta _ Test Storybook · GitLab

The fact that the issue only occurs in your CI/CD pipeline and not locally suggests a potential resource issue with your CI agents. If it were an SDK issue, we would expect to encounter it locally as well.

We recommend raising a support ticket with Browserstack to investigate further. Please initiate this so that we can collaborate and resolve the issue promptly.

github-actions[bot] commented 2 months ago

This issue is stale because it has been open for more than 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.

github-actions[bot] commented 1 month ago

This issue was closed because it has been stalled for 28 days with no activity.