mardi 22 décembre 2020

Cypress | Docker and cypress included 6.1.0, complains about missing plugins

From following this helpful link: https://www.cypress.io/blog/2019/05/02/run-cypress-with-a-single-docker-command/

And mass googling (a few links as example):

https://github.com/cypress-io/cypress-docker-images/issues/265

https://github.com/cypress-io/cypress-docker-images/issues/178

I've managed to get the tests running correctly without plugin/support (by setting them to false in cypress config). BUT when I want to use cypress-axe to test accessibility and use docker, I receive the following.

The command to execute:

docker run -it -v $PWD:/e2e -w /e2e cypress/included:6.1.0 --spec "**/components/button.spec.js"

The resulting error:

Error: Cannot find module 'cypress-axe' from '/e2e/tests/UI/cypress/support'


This occurred while Cypress was compiling and bundling your test code. This is usually caused by:

- A missing file or dependency
- A syntax error in the file or one of its dependencies

Fix the error in your code and re-run your tests.

Also dependent on what version of the cypress included I use also get another error (I believe this error is coming from .babelrc, again missing plugin issue):

Error: Webpack Compilation Error
./tests/UI/cypress/integration/components/button.spec.js
Module build failed (from /root/.cache/Cypress/6.2.0/Cypress/resources/app/packages/server/node_modules/babel-loader/lib/index.js):
Error: Cannot find module '@babel/plugin-syntax-dynamic-import'

So, by the looks of the errors it cannot find any installed plugin dependencies as the dependencies are not inside the image/container as of yet. Which makes sense. I was wondering is there a way to leverage the cypress-axe plugin all from this one command? Something like:

docker run -it -v $PWD:/e2e -w /e2e cypress/included:6.1.0 /bin/bash -c 'npm install cypress-axe && cypress run --spec "**/components/button.spec.js"'

BUT wanting to avoid creating a docker file and just use one command to run cypress inside docker and use plugins. Along with caching this as we do not want to install the plugins each time we run the command.

Any suggestions would be much appreciated!

Aucun commentaire:

Enregistrer un commentaire