ccpu / storybook-addon-playwright

An addon to visually test the stories in the multiple browser within storybook environment
MIT License
55 stars 13 forks source link

Error: Configuration has not been set. #33

Closed XiaoW9596 closed 2 years ago

XiaoW9596 commented 2 years ago

Hi there, thanks for this amazing addon!

I followed your guide and went through all documentation and issues, but I got Configuration has not been set. status code 500 error with api call /screenshot/getand getTheme. I also tried your example repo, same api error also appeared.

I know that this error message indicates setConfig() is empty or not properly read, but I did put required setConfig() as documentation, and I couldn't figure out the way to fix this.

This is a screenshot of error when I run your example repo:

Screen Shot 2022-02-17 at 5 59 09 PM

This is a screenshot of error when I run my own repo: Screen Shot 2022-02-18 at 12 07 54 PM

Also, even after I delete setConfig() script in main.js, the screenshot/get api still calls for all browsers: Screen Shot 2022-02-18 at 12 08 01 PM

I'm not sure if I missed anything as configuration / setup. Thanks in advance for your help!

ccpu commented 2 years ago

Hi, this error occurs when setConfig is not set correctly or playwright has not been installed correctly. Make sure only to install supported playwright@1.17.x,storybook@6.4.x and @storybook/addon-knobs@6.4.x. Alternatively, an error may have been thrown inside setConfig; for example, if playwright is not installed properly, it may throw an error when unable to get new page. Additionally, be sure to place the setConfig inside the .storybook/main.js file. You need to place consol.log at a different stage of the .storybook/main.js&setConfig file to debug and figure out why setConfig fails.

XiaoW9596 commented 2 years ago

Hi there, thanks for the quick reply! I installed corresponding package version for playwright, storybook and storybook/addon-knobs and placed setConfig inside main.js. With different console.log(), I think the error originate from UnhandledPromiseRejectionWarning: browserType.launch: Browser closed.

ccpu commented 2 years ago

Despite this, I am unable to help you much when it comes to the playwright environment. Are you able to launch the playwright browser without this plugin? You can check playwright functionality by running the following code in NodeJS. (try to run this code with all browser Chromium, Firefox, Webkit)

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch()
  const page = await browser.newPage()
  await page.setViewportSize({ width: 1280, height: 800 })
  await page.goto('https://playwright.dev/')
  await page.screenshot({ path: 'my_screenshot.png' })
  await browser.close()
})()
XiaoW9596 commented 2 years ago

Hi there, I fixed the error!!! I upgrade the node version to 14.15.0, and then install playwright. Everything works fine right now!

XiaoW9596 commented 2 years ago

I also runned

npm i -D @playwright/test
# install supported browsers
npx playwright install

from https://playwright.dev/docs/1.17/intro

ccpu commented 2 years ago

Nice one, now that you have solved the problem, I am closing the issue.