tyler36 / ddev-cypress

Cypress E2E testing for use with DDEV
Apache License 2.0
11 stars 9 forks source link

Can't install plugins inside cypress container #48

Open bserem opened 1 week ago

bserem commented 1 week ago

Coming from Behat I am evaluating Cypress and loving it so far, however I have a legacy of tests written in Cucumber (and I find it easier to write) so I am experimenting with official plugins that allow Cucumber syntax in Cypress.

When I try to install custom cypress plugins via NPM I am getting this error:

npm error Your cache folder contains root-owned files, due to a bug in
npm error previous versions of npm which has since been addressed.
npm error
npm error To permanently fix this problem, please run:
npm error   sudo chown -R 6001:6001 "/root/.npm"
npm error Log files were not written due to an error writing to the directory: /root/.npm/_logs
npm error You can rerun the command with `--loglevel=verbose` to see the logs in your terminal

I tried it with a simple approach first, adding my custom commands in the entrypoint:

    entrypoint: /bin/bash -c "npm install @bahmutov/cypress-esbuild-preprocessor @badeball/cypress-cucumber-preprocessor"

SSHing into the cypress container and trying to chmod the folder was not possible either, as sudo is not available.

Am I missing something or is this a problem with the official dockerimage?

rfay commented 1 week ago

You probably have to add a build: section in the docker-compose.cypress.yaml

@tyler36 is out for a few weeks but will be back :)

bserem commented 5 days ago

The build section kind of worked. I added a custom dockerfile like:

FROM cypress/included:13.15.2

# Set the working directory
WORKDIR /e2e

# Install npm package(s)
RUN npm install -g @bahmutov/cypress-esbuild-preprocessor @badeball/cypress-cucumber-preprocessor && npm cache clean --force

The container starts now, no issues there. But the plugins are still not installed, or not discoverable by Cypress.

Thanks for info and docker lessons, I'll get to the bottom of it :)