TestCafe usage with Docker – Socket Hang Up – Cannot establish one or more browser connections Errors

I am trying to run TestCafe tests inside docker container.

I am able to run my tests with npm run testrunner locally. Inside Docker container, I get different errors on different tries.

The errors I get are as follows:

With firefox:headless --no-sandbox --disable-dev-shm-usage option:

...-tests  | Error: Cannot establish one or more browser connections.
...-tests  | 3 of 3 browser connections have not been established:
...-tests  | - firefox:headless --no-sandbox --disable-dev-shm-usage
...-tests  | - firefox:headless --no-sandbox --disable-dev-shm-usage
...-tests  | - firefox:headless --no-sandbox --disable-dev-shm-usage
...-tests  | 
...-tests  | Hints:
...-tests  | - 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.
...-tests  | - 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.

With chromium:headless --no-sandbox --disable-dev-shm-usage option:

...-tests  | Error: Unable to open the "chromium:headless --no-sandbox --disable-dev-shm-usage" browser due to the following error:
...-tests  | 
...-tests  | Error: WebSocket connection closed
...-tests  |     at /app/node_modules/chrome-remote-interface/lib/chrome.js:94:35
...-tests  |     at Chrome._handleConnectionClose (/app/node_modules/chrome-remote-interface/lib/chrome.js:256:13)
...-tests  |     at WebSocket.<anonymous> (/app/node_modules/chrome-remote-interface/lib/chrome.js:243:22)
...-tests  |     at WebSocket.emit (node:events:518:28)
...-tests  |     at WebSocket.emit (node:domain:488:12)
...-tests  |     at WebSocket.emitClose (/app/node_modules/ws/lib/websocket.js:246:10)
...-tests  |     at Socket.socketOnClose (/app/node_modules/ws/lib/websocket.js:1148:15)
...-tests  |     at Socket.emit (node:events:518:28)
...-tests  |     at Socket.emit (node:domain:488:12)
...-tests  |     at TCP.<anonymous> (node:net:337:12)
...-tests  |     at BrowserConnection._runBrowser (/app/node_modules/testcafe/src/browser/connection/index.ts:291:32)

With chromium:headless --no-sandbox --disable-dev-shm-usage option and const testcafe = await createTestCafe({ experimentalProxyless: true }); initialization:

...-tests  | Error: Unable to open the "chromium:headless --no-sandbox --disable-dev-shm-usage" browser due to the following error:
...-tests  | 
...-tests  | Error: socket hang up
...-tests  |     at Socket.socketOnEnd (node:_http_client:524:23)
...-tests  |     at Socket.emit (node:events:530:35)
...-tests  |     at Socket.emit (node:domain:488:12)
...-tests  |     at endReadableNT (node:internal/streams/readable:1696:12)
...-tests  |     at processTicksAndRejections (node:internal/process/task_queues:82:21)
...-tests  |     at BrowserConnection._runBrowser (/app/node_modules/testcafe/src/browser/connection/index.ts:291:32)
...-tests  |     at processTicksAndRejections (node:internal/process/task_queues:95:5)

package.json

{
  ...
  "scripts": {
    ...
    "cafe:prod:h:3": "npx testcafe 'firefox:headless --no-sandbox --disable-dev-shm-usage' src/tests/masterdata",
    "testrunner": "node runner.js"
  },
  "dependencies": {
    "@aws-sdk/client-ssm": "^3.535.0",
    "aws-sdk": "^2.1582.0",
    "dotenv": "^16.4.5",
    "downloads-folder": "^3.0.3"
  }
}

runner.js

const createTestCafe = require('testcafe');

(async function () {
  const testcafe = await createTestCafe({ experimentalProxyless: true });
  try {
    const runner = testcafe.createRunner();
    const failed = await runner
      .src(['src/tests/masterdata'])
      .browsers('chromium:headless --no-sandbox --disable-dev-shm-usage')
      .concurrency(3)
      .run();

    console.log('Tests failed: ' + failed);
  } finally {
    await testcafe.close();
  }
})();

What do I need to run tests in Docker?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật