cypress-testing-library icon indicating copy to clipboard operation
cypress-testing-library copied to clipboard

Build Error While Integrating Cypress Testing Library on Gitlab CI/CD

Open aman2810khan opened this issue 3 years ago • 4 comments

I have installed DOM and Cypress testing library modules in my react project :

npm install --save-dev @testing-library/dom npm install --save-dev @testing-library/cypress

As mentioned in testing library docs , I have added the following import statement in cypress/support/commands.js : import '@testing-library/cypress/add-commands';

The problem is node_modules is present in my .gitignore file and when the pipeline runs the cypress tests (files with extension .spec.js) on Gitlab ,it throws the following error : Module not found: Error: Can't resolve '@testing-library/cypress/add-commands'

Is there any alternate way for using the cypress testing library commands?

aman2810khan avatar Apr 13 '22 10:04 aman2810khan

Hi even I observe the same error when I run my scripts in browserStack. Any alternatives or fix for this please?

Running: movSvc/testCaseCheckTest.spec.js

Oops...we found an error preparing this test file:

cypress\support\index.js

The error was:

Error: Webpack Compilation Error ./cypress/support/commands.js Module not found: Error: Can't resolve '@testing-library/cypress/add-commands' in 'cypress_test_folder\cypress\support' resolve '@testing-library/cypress/add-commands' in 'cypress_test_folder\cypress\support' Parsed request is a module using description file: cypress_test_folder\package.json (relative path: ./cypress/support) Field 'browser' doesn't contain a valid alias configuration Looked for and couldn't find the file at the following paths: [cypress_test_folder\cypress\support\node_modules] [cypress_test_folder\cypress\node_modules] [node_modules]

amruth963 avatar Sep 19 '22 14:09 amruth963

@aman2810khan did you find a solution? We have the same error on Github actions. Locally it runs fine.

rmcsharry avatar Dec 05 '22 13:12 rmcsharry

I had an old import in my command.js file removing the import got rid of the error.

snake-py avatar Dec 21 '22 13:12 snake-py

@aman2810khan @amruth963 @rmcsharry did you guys figured it out ? I am facing this issue while integrating with lambdatest, locally it is running fine. Using [email protected]

For me, while running on github actions it is running fine.

ravinder58 avatar Jan 09 '23 22:01 ravinder58