Cypress seems to be trying to read the test files from entirely the wrong place (the HTTPS version of the CYPRESS_BASE_URL environment variable and the tests/ directory), when I run it in a docker-compose network. As the app I'm testing doesn't serve those files, this fails.
When I run the E2E tests normally, they pass: https://circleci.com/gh/textbook/starter-kit/443
However, when I run them in a network using docker-compose, they crash https://circleci.com/gh/textbook/starter-kit/437
The error message is:
ERR_CONNECTION_CLOSED (-100) loading 'https://app/__/#/tests/integration/home.test.js'
which suggests that Cypress is looking for the test files at the CYPRESS_BASE_URL and in the wrong directory; in that project (https://github.com/textbook/starter-kit) my integrationFolder is /e2e/integration.
It also mentions Fontconfig warning: "/etc/fonts/fonts.conf", line 100: unknown element "blank" as Cypress starts - I don't know if this is related, but it doesn't happen in the success case.
I would like the Docker version to behave normally; I use this setup to regression test my code against multiple versions of Node.
Test example repo: https://github.com/textbook/cypress-test-tiny/tree/recreate-base-url-issue
If you run Cypress in the container network (npm run cypress:docker), it fails with an error similar to the above complaint (and again looks in /tests, not /cypress):
ERR_CONNECTION_CLOSED (-100) loading 'https://app/__/#/tests/integration/spec.js'
If you start the app (npm start) and then run Cypress with a base URL (CYPRESS_BASE_URL=http://localhost:3000 npm run cypress:run), it seems fine, suggesting that it's not _just_ the setting of the URL that's the problem.
Cypress: 3.5.0 (I noticed this because it started failing when Dependabot PRd the upgrade: textbook/starter-kit#24)
OS: macOS 10.14.6 locally, also fails on CircleCI remotely
This happens with both cypress/included:3.5.0 and cypress/included:3.3.1; my first assumption was the problem was in trying to run Cypress 3.5 in the older image, but upgrading didn't help.
Bafflingly, when Dependabot rebased the PR and the tests re-ran (https://circleci.com/gh/textbook/starter-kit/528), they worked, and when I re-run the example repo it works too. Don't know what changed over the weekend, but I'll close this out for now.
This has come up again - a bunch more PRs from Dependabot (from https://github.com/textbook/starter-kit/pull/87) have failed for the same reason as above. I've updated the example and it's failing locally again: https://github.com/textbook/cypress-test-tiny/tree/recreate-base-url-issue
Cypress and cypress/included v3.8.0.
This still happens if I build my own E2E container, based on https://docs.cypress.io/guides/guides/continuous-integration.html#Dependencies, so it's not a problem with cypress/included:
FROM node:12.13.0-buster-slim
RUN apt-get update && apt-get install -y xvfb libgtk-3-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2
...
I'm also seeing this after moving our CI Cypress runs from using --network="host" to docker-compose or manually setting up shared bridge network.
Looks like this is related to #2996 and HSTS. I was using the service name app, and Cypress baseUrl http://app. Changed to something much more specific to our application and bingo, the tests are found over http.
@jakewisse you're right, nice catch; if I change the app name in docker-compose.yml to e.g. my-test-app it passes just fine:
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,6 +1,6 @@
version: '3.3'
services:
- app:
+ my-test-app:
build:
context: .
dockerfile: Dockerfile-app
@@ -9,6 +9,6 @@ services:
context: .
dockerfile: Dockerfile-e2e
environment:
- - CYPRESS_BASE_URL=http://app
+ - CYPRESS_BASE_URL=http://my-test-app
links:
- - app
+ - my-test-app
after some testing i found out that it had been broken here
cypress/included:3.8.1 -> cypress/included:3.8.2
Wow, I had the exact same problem.
This really needs to be fixed or at least a warning should be displayed. I have wasted quite some time before finding this.
Thanks for sharing @Hulkmaster