I have an issue with my docker and cypress from Windows machine.
I am using git bash
to run my e2e.sh
script. All is happening on windows level.
My script looks like this:
#!/bin/bash
# Copy .e2e.npmrc file to .npmrc
cp .e2e.npmrc .npmrc
if [[ $1 == "clear" ]]; then
# Build Docker image with no cache
echo "Building Docker image..."
docker build -t front-e2e .
# Stop and remove any existing container with the same name
echo "Stopping and removing existing container..."
docker stop front-e2e
docker rm front-e2e
# Set NPM_TOKEN environment variable
if [[ -z "${NPM_TOKEN}" ]]; then
export NPM_TOKEN=$(cat ~/.npmrc | grep -o '_authToken=.*' | head -1 | sed
's/_authToken=//g')
fi
# Run Docker container with bind mount and environment variable
echo "Running Docker container..."
docker run -d --name front-e2e -e NPM_TOKEN=${NPM_TOKEN} --mount
type=bind,source="C:\Users\myUser\Desktop\projects\front-mobile-web",target=/front-
mobile-web,consistency=full -v /front-mobile-web/node_modules -t front-e2e
# Install dependencies and list files in /front-mobile-web directory
echo "Installing dependencies..."
docker exec front-e2e yarn install -w /front-mobile-web
fi
# Run e2e tests
echo "Running e2e tests..."
docker exec front-e2e yarn nx run export-app-e2e:e2e -w "C:\Users\myUser\Desktop\projects\front-mobile-web"
# Remove .npmrc file
rm .npmrc
So here
docker run -d --name front-e2e -e NPM_TOKEN=${NPM_TOKEN} --mount
type=bind,source="C:\Users\myUser\Desktop\projects\front-mobile-web",target=/front-
mobile-web,consistency=full -v /front-mobile-web/node_modules -t front-e2e
I am binding my windows folder.
In Docker
file i have this:
FROM node:18
RUN apt update
RUN apt install xvfb libgconf-2-4 libatk1.0-0 libatk-bridge2.0-0 libgdk-pixbuf2.0-0 libgtk-3-0 libgbm-dev libnss3-dev libxss-dev libasound2 -y
RUN useradd -d /home/air -m -s /bin/bash air
RUN mkdir -p /front-mobile-web ; chown -R air:air /front-mobile-web
RUN mkdir -p /front-mobile-web/node_modules ; chown -R air:air /front-mobile-web/node_modules
VOLUME ["/front-mobile-web"]
USER air
WORKDIR /front-mobile-web
Thanks to that i can sart my e2e.sh
script and it is almost working. It is creating container stopping deleting and even binding my folder, but I have two issues.
One is during Linking dependencies
:
error An unexpected error occurred: "EIO: i/o error, unlink '/front-mobile-web/node_modules/@parcel/watcher/prebuilds/win32-x64/node.napi.glibc.node'".
info If you think this is a bug, please open a bug report with the information provided in "/front-mobile-web/yarn-error.log".
and second is when my e2e test is running:
No version of Cypress is installed in: /home/air/.cache/Cypress/12.9.0/Cypress
Please reinstall Cypress by running: cypress install
----------
Cypress executable not found at: /home/air/.cache/Cypress/12.9.0/Cypress/Cypress
----------
Platform: linux-x64 (Debian - 11.6)
Cypress Version: 12.9.0
In my node_modules
I do have cypress installed and i can run cypress tests localy from electron with no issues
Getting to this point took me like whole week and in general this is only issue that I have right now with this