DevExpress / testcafe

A Node.js tool to automate end-to-end web testing.
https://testcafe.io
MIT License
9.78k stars 661 forks source link

Error: connect ECONNREFUSED 127.0.0.1:34261 - trying to run tests in Docker #8187

Closed akaribrahim closed 1 month ago

akaribrahim commented 1 month ago

What is your Scenario?

When I try to run a simple test with the TestCafe Docker image, I get an error. I am using M1 Silicon Mac. TestCafe cannot connect Chrome or any browser.

What is the Current behavior?

Connection Refused error when I try with TestCafe official Docker image.


docker run -v ${PWD}/src/tests:/tests -it testcafe/testcafe chromium tests/simpleTest.js

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
ERROR Unable to open the "chromium:" browser due to the following error:

Error: connect ECONNREFUSED 127.0.0.1:40201
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16)
    at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17)

docker run -v ${PWD}/src/tests:/tests -it testcafe/testcafe chromium:headless tests/simpleTest.js

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
ERROR Cannot establish one or more browser connections.
1 of 1 browser connections have not been established:
- chromium:headless

Hints:
- Increase the Browser Initialization Timeout if its value is too low (currently: 2 minutes for local browsers and 6 minutes for remote browsers). The timeout determines how long TestCafe waits for browsers to be ready.
- The error can also be caused by network issues or remote device failure. Make sure that your network connection is stable and you can reach the remote device.

docker run -v ${PWD}/src/tests:/tests -it testcafe/testcafe firefox:headless tests/simpleTest.js

WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
ERROR Cannot establish one or more browser connections.
1 of 1 browser connections have not been established:
- firefox:headless

Hints:
- Increase the Browser Initialization Timeout if its value is too low (currently: 2 minutes for local browsers and 6 minutes for remote browsers). The timeout determines how long TestCafe waits for browsers to be ready.
- The error can also be caused by network issues or remote device failure. Make sure that your network connection is stable and you can reach the remote device.

What is the Expected behavior?

Tests run locally. I expect it to work with Docker image as well.

What is the public URL of the test page? (attach your complete example)

To reproduce:

Pull latest testcafe image. docker pull testcafe/testcafe

Write a simple testcode and run docker run command. docker run -v ${PWD}/src/tests:/tests -it testcafe/testcafe chromium tests/simpleTest.js

What is your TestCafe test code?

fixture('Getting Started').page('https://devexpress.github.io/testcafe/example');

test('My first test', async (t) => {
  const developerNameInput = Selector('#developer-name');

  // Populate the developer name field
  await t.typeText(developerNameInput, 'Peter');
  const developerName = Selector('#developer-name').value;

  await t.expect(developerName).eql('Peter');
});

Your complete configuration file

No response

Your complete test report

No response

Screenshots

No response

Steps to Reproduce

  1. docker pull testcafe/testcafe
  2. Write a simple test.
  3. docker run -v ${PWD}/src/tests:/tests -it testcafe/testcafe chromium tests/simpleTest.js

TestCafe version

latest testcafe image

Node.js version

No response

Command-line arguments

docker run -v ${PWD}/src/tests:/tests -it testcafe/testcafe chromium tests/simpleTest.js

Browser name(s) and version(s)

No response

Platform(s) and version(s)

No response

Other

No response

Bayheck commented 1 month ago

Hello, TestCafe does not have an 'arm' docker image. Please refer to the following StackOveflow thread: https://stackoverflow.com/questions/67458621/how-to-run-amd64-docker-image-on-arm64-host-platform.

As a workaround, you can create your own TestCafe image, which is compatible with Linux/arm64/v8. Use our Dockerfile[https://github.com/DevExpress/testcafe/blob/1b17abddd46ba3575d044a0cd8c73deac424ec14/docker/Dockerfile] for this purpose.