2

I set up a Shopware 6 project with ddev. Now I want to write cypress tests for one of my plugins. The shopware testsuite starts a node express server on port 8005 in the web container. I have configured the port for ddev so that I can open the express endpoint in my browser: http://my.ddev.site:8005/cleanup. That is working.

For cypress I have created a new ddev container with a new docker-compose file:

version: '3.6'
services:
  cypress:
    container_name: ddev-${DDEV_SITENAME}-cypress
    image: cypress/included:4.10.0
    tty: true
    ipc: host
    links:
      - web:web
    environment:
      - CYPRESS_baseUrl=https://web
      - DISPLAY
    labels:
      com.ddev.site-name: ${DDEV_SITENAME}
      com.ddev.approot: $DDEV_APPROOT
    volumes:
      # Project root
      - ../shopware:/project
      # Storefront and Administration
      - ../shopware/vendor/shopware/platform/src/Storefront/Resources/app/storefront/test/e2e:/e2e-Storefront
      - ../shopware/vendor/shopware/platform/src/Administration/Resources/app/administration/test/e2e:/e2e-Administration
      # Custom plugins
      - ../shopware/custom/plugins/MyPlugin/src/Resources/app/administration/test/e2e:/e2e-MyPlugin
      # for Cypress to communicate with the X11 server pass this socket file
      # in addition to any other mapped volumes
      - /tmp/.X11-unix:/tmp/.X11-unix
    entrypoint: /bin/bash

I can now successfully open the cypress interface and I see my tests. The problem is now, that always before a cypress test is executed, the express endpoint is called (with the URL from above) and the cypress container seems to has no access to the endpoint. This is the output:

cy.request() failed trying to load:

http://my.ddev.site:8005/cleanup

We attempted to make an http request to this URL but the request failed without a response.

We received this error at the network level:

  > Error: connect ECONNREFUSED 127.0.0.1:8005

-----------------------------------------------------------

The request we sent was:

Method: GET
URL: http://my.ddev.site:8005/cleanup

So I can call this endpoint in my browser, but cypress can't. Is there any configuration in the cypress container missing to call the port 8005 from the web container?

Nono
  • 1,073
  • 4
  • 23
  • 46

1 Answers1

2

You need to add this to the cypress service:

external_links:
  - "ddev-router:${DDEV_HOSTNAME}"

and then your http URL will be accessed through the router via ".ddev.site".

If you need a trusted https URL it's a little more complicated, but for http this should work fine.

rfay
  • 9,963
  • 1
  • 47
  • 89