1

I have pulled the image using below command into my root of the project

docker pull mcr.microsoft.com/playwright:v1.24.2-focal

and then run the image using below command:

docker run -it --rm --ipc=host mcr.microsoft.com/playwright:v1.24.2-focal /bin/bash

and it takes me to the container (please check screenshot below)

enter image description here

when I run the command npx playwright test my all test got passed but when I tried to open test report using command: npx playwright show-report then it shows me below result:

enter image description here

It says:

Failed to open browser on http://127.0.0.1:9323

What can I try to resolve this?

enter image description here

syed1234
  • 761
  • 5
  • 12
  • 30
  • 1
    Playwright tries to open the HTML report inside your Docker container, but that is not working since you don't have a browser with a GUI inside the container. Set "open: never" inside your config and manually open the HTML report on your host via double click on the playwright-report/index.html site. See here https://playwright.dev/docs/test-reporters#html-reporter – Max Schmitt Aug 07 '22 at 21:40
  • Hi halfer, thankyou for the tip. I have one more question to that I have different folder in my project containing backend and frontend and while I am in the container as I mentioned above the test files are not created in my pr oject rather it is created inside the container(pls check screenshot) I have attached. the problem is how to work here with these files because these files are not created into my project? – syed1234 Aug 08 '22 at 09:49
  • How I can create those files inside my project so I can create tests and open my test reports? – syed1234 Aug 08 '22 at 09:53

1 Answers1

2

Max is right, you have to add for example in your playwright.config.ts the option open: 'never'. For example:

const config: PlaywrightTestConfig = {
  // (...)
  reporter: [ ['html', { open: 'never'}], ['list'] ],
  // (...)
}

And to answer to your second question, about getting the reports on your host, you have to use a volume when executing docker run.

For example, let's say that on your host, in your current folder, you have your playwright.config.ts file, then run the following command to mount the whole directory on the container:

docker run -it --rm --ipc=host \
  --workdir=/my_tests \
  -v $PWD:/my_tests \
  mcr.microsoft.com/playwright:v1.24.2-focal bash
Tristan
  • 36
  • 1