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

Error output if a test fail says "page.evaluate: Browser has been closed" #336

Closed
kevinsimper opened this issue Jul 27, 2023 · 5 comments · Fixed by #397
Closed

Error output if a test fail says "page.evaluate: Browser has been closed" #336

kevinsimper opened this issue Jul 27, 2023 · 5 comments · Fixed by #397
Assignees
Labels
bug Something isn't working released sev:S2

Comments

@kevinsimper
Copy link

Describe the bug
Trying out the test-runner on a new storybook setup, but the error when the test-runner encounter a runtime error seems like a bug. It does not tell you which test that failed and why right away. When I first saw it looked like a bug in the test runner.

It can be it is intentional, but there were no issues mentioning "page.evaluate: Browser has been closed" this issue can just be closed :)

To Reproduce
Can be reproduced here
https://github.com/kevinsimper/test-storybook-testrunner

I have added a throw new Error in page.jsx

$ npm test

> [email protected] test
> test-storybook

 PASS   browser: chromium  stories/Header.stories.js
 PASS   browser: chromium  stories/Button.stories.js
page.evaluate: Browser has been closed
    ==== Closed by ====
    at CustomEnvironment.teardown (/node_modules/jest-playwright-preset/lib/PlaywrightEnvironment.js:239:78)
    at CustomEnvironment.teardown (/node_modules/@storybook/test-runner/playwright/custom-environment.js:12:17)
    at runTestInternal (/node_modules/jest-runner/build/runTest.js:485:23)
    at runTest (/node_modules/jest-runner/build/runTest.js:499:34)
    at Object.worker (/node_modules/jest-runner/build/testWorker.js:133:12)

    at Page.<anonymous> (/stories/Page.stories.js:146:58)

Node.js v18.4.0
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

page.evaluate: Browser has been closed
    ==== Closed by ====
    at CustomEnvironment.teardown (/node_modules/jest-playwright-preset/lib/PlaywrightEnvironment.js:239:78)
    at CustomEnvironment.teardown (/node_modules/@storybook/test-runner/playwright/custom-environment.js:12:17)
    at runTestInternal (/node_modules/jest-runner/build/runTest.js:485:23)
    at runTest (/node_modules/jest-runner/build/runTest.js:499:34)
    at Object.worker (/node_modules/jest-runner/build/testWorker.js:133:12)

    at Page.<anonymous> (/stories/Page.stories.js:146:58)

Node.js v18.4.0
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

page.evaluate: Browser has been closed
    ==== Closed by ====
    at CustomEnvironment.teardown (/node_modules/jest-playwright-preset/lib/PlaywrightEnvironment.js:239:78)
    at CustomEnvironment.teardown (/node_modules/@storybook/test-runner/playwright/custom-environment.js:12:17)
    at runTestInternal (/node_modules/jest-runner/build/runTest.js:485:23)
    at runTest (/node_modules/jest-runner/build/runTest.js:499:34)
    at Object.worker (/node_modules/jest-runner/build/testWorker.js:133:12)

    at Page.<anonymous> (/stories/Page.stories.js:146:58)

Node.js v18.4.0
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

page.evaluate: Browser has been closed
    ==== Closed by ====
    at CustomEnvironment.teardown (/node_modules/jest-playwright-preset/lib/PlaywrightEnvironment.js:239:78)
    at CustomEnvironment.teardown (/node_modules/@storybook/test-runner/playwright/custom-environment.js:12:17)
    at runTestInternal (/node_modules/jest-runner/build/runTest.js:485:23)
    at runTest (/node_modules/jest-runner/build/runTest.js:499:34)
    at Object.worker (/node_modules/jest-runner/build/testWorker.js:133:12)

    at Page.<anonymous> (/stories/Page.stories.js:146:58)

Node.js v18.4.0
 FAIL   browser: chromium  stories/Page.stories.js
  ● Test suite failed to run

    Jest worker encountered 4 child process exceptions, exceeding retry limit

      at ChildProcessWorker.initialize (node_modules/jest-runner/node_modules/jest-worker/build/workers/ChildProcessWorker.js:170:21)

Test Suites: 1 failed, 2 passed, 3 total
Tests:       6 passed, 6 total
Snapshots:   0 total
Time:        9.683 s
Ran all test suites.

Without the throw error, it works fine

$ npm test

> [email protected] test
> test-storybook

 PASS   browser: chromium  stories/Header.stories.js
 PASS   browser: chromium  stories/Button.stories.js
 PASS   browser: chromium  stories/Page.stories.js

Test Suites: 3 passed, 3 total
Tests:       8 passed, 8 total
Snapshots:   0 total
Time:        3.599 s
Ran all test suites.
@kevinsimper kevinsimper changed the title [bug] Error output if a test fail says "page.evaluate: Browser has been closed" Jul 27, 2023
@lostdev
Copy link

lostdev commented Aug 16, 2023

Having the same issue here.

@IanVS
Copy link
Member

IanVS commented Sep 12, 2023

I'm also seeing this happen, but only occasionally. I agree it would be great to give as much context as possible here about what failed and why, ideally with a stacktrace back to the original error. At the very least, it should be clear which test failed, which I find isn't always the case.

@brycefranzen
Copy link

I'm having the same issue :/

"storybook": "^7.5.2",
"@storybook/test-runner": "^0.13.0",
"@testing-library/react": "^14.0.0",
"@storybook/testing-library": "^0.2.2",

@yannbf yannbf added the bug Something isn't working label Nov 2, 2023
@kasper573
Copy link

This happened to me as well. I was using https://vanilla-extract.style/ with Vite, which precompiles .css.ts files to .css in the bundling step. I was getting an error inside vanilla-extract because I was using it incorrectly, but I think because the error was being thrown in the bundler step it made it problematic for storybook to elegantly collect error information. Adding this message in case it helps debugging this issue!

Copy link

🚀 Issue was released in v0.15.2 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working released sev:S2
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

7 participants