Skip to content

Support testing with Firefox in air-gapped environment (Docker) #1348

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
MikeMcC399 opened this issue May 14, 2025 · 3 comments
Open

Support testing with Firefox in air-gapped environment (Docker) #1348

MikeMcC399 opened this issue May 14, 2025 · 3 comments

Comments

@MikeMcC399
Copy link
Collaborator

What would you like?

Give the cypress/factory Cypress Docker image, and associated process, the ability to generate other Cypress Docker images that do not require an Internet connection when testing against Firefox.

In an air-gapped environment, testing against Firefox:

  • Allow custom images, built from cypress/factory, cypress/base or cypress/browsers to test successfully.

  • Allow cypress/included images to test successfully out of the box.

Why is this needed?

Other

Steps to reproduce

With Internet connection

docker pull cypress/included:latest
git clone https://github.com/cypress-io/cypress-docker-images
cd cypress-docker-images
cd examples/basic-mini

Disconnect network and attempt to execute, testing against Firefox, which fails trying to download a missing driver:

docker run -it --rm -v .:/app -w /app --entrypoint cypress cypress/included run -b firefox

Logs

$ docker run -it --rm -v .:/app -w /app --entrypoint cypress cypress/included run -b firefox


DevTools listening on ws://127.0.0.1:43731/devtools/browser/69952a44-27ba-4382-a915-71bd5a5eb6ad

====================================================================================================

  (Run Starting)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Cypress:        14.3.3                                                                         │
  │ Browser:        Firefox 138 (headless)                                                         │
  │ Node Version:   v22.15.0 (/usr/local/bin/node)                                                 │
  │ Specs:          1 found (spec.cy.js)                                                           │
  │ Searched:       cypress/e2e/**/*.cy.{js,jsx,ts,tsx}                                            │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘


────────────────────────────────────────────────────────────────────────────────────────────────────

  Running:  spec.cy.js                                                                      (1 of 1)
Cypress failed to make a connection to Firefox.

This usually indicates there was a problem opening the Firefox browser.

FetchError: request to https://raw.githubusercontent.com/mozilla/geckodriver/release/Cargo.toml failed, reason: getaddrinfo ENOTFOUND raw.githubusercontent.com
    at ClientRequest.<anonymous> (file:///root/.cache/Cypress/14.3.3/Cypress/resources/app/packages/server/node_modules/node-fetch/src/index.js:108:11)
    at ClientRequest.emit (node:events:518:28)
    at emitErrorEvent (node:_http_client:101:11)
    at TLSSocket.socketErrorListener (node:_http_client:504:5)
    at TLSSocket.emit (node:events:518:28)
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
@MikeMcC399
Copy link
Collaborator Author

Breaking change Cypress 13.15.1

The requirement for an Internet connection was introduced by [email protected]. For air-gapped users of Cypress Docker images, this was a breaking change.

Running the steps to reproduce with the version [email protected], before the migration to geckodriver, succeeds to test with Firefox.

Connected to Internet:

docker pull cypress/included:13.15.0

then disconnected from Internet:

docker run -it --rm -v .:/app -w /app --entrypoint cypress cypress/included:13.15.0 run -b firefox # succeeds

@MikeMcC399 MikeMcC399 changed the title Support testing with Firefox in air-gapped environment Support testing with Firefox in air-gapped environment (Docker) May 14, 2025
@MikeMcC399 MikeMcC399 self-assigned this May 15, 2025
@MikeMcC399
Copy link
Collaborator Author

Assessment

GECKODRIVER_AUTO_INSTALL

According to geckodriver > README > Installing, the environment variable setting GECKODRIVER_AUTO_INSTALL=1 can be used to install the driver together with npm dependencies.

This does not immediately apply to the cypress npm package, because the geckodriver is not a dependency of the npm package (view on https://www.npmjs.com/package/cypress?activeTab=code), instead the driver wrapper geckodriver is bundled into the Cypress binary through https://github.com/cypress-io/cypress/blob/develop/packages/server/package.json

GECKODRIVER_PATH

geckodriver > README > Options > customGeckoDriverPath lists

customGeckoDriverPath

Don't download Geckodriver, instead use a custom path to it, e.g. a cached binary.

Type: string
Default: process.env.GECKODRIVER_PATH

Proof of Concept

Using GECKODRIVER_PATH

git clone https://github.com/cypress-io/cypress-docker-images
cd cypress-docker-images
cd examples/basic
cp Dockerfile.browsers Dockerfile.firefox-geckodriver
npm ci

Edit Dockerfile.firefox-geckodriver and add the following to the end of the file:

RUN wget -O /tmp/geckodriver.tar.gz \
https://github.com/mozilla/geckodriver/releases/download/v0.36.0/geckodriver-v0.36.0-linux64.tar.gz
RUN tar -C /opt -xaf /tmp/geckodriver.tar.gz
RUN rm /tmp/geckodriver.tar.gz
ENV GECKODRIVER_PATH=/opt/geckodriver

Execute build command with Internet connection:

docker build --progress plain -f Dockerfile.firefox-geckodriver -t test-firefox-geckodriver .

Disconnect network and execute:

docker run -it --rm --entrypoint bash test-firefox-geckodriver -c "npx cypress run -b firefox"

Firefox runs successfully.

Recommendation

Further research if installing a geckodriver together with Firefox can be integrated into the Factory build process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant