Skip to content
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

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

Open
aman2810khan opened this issue Apr 13, 2022 · 4 comments
Open

Comments

@aman2810khan
Copy link

aman2810khan commented Apr 13, 2022

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?

@amruth963
Copy link

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]

@rmcsharry
Copy link

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

@snake-py
Copy link

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

@ravinder58
Copy link

ravinder58 commented Jan 9, 2023

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

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

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

No branches or pull requests

5 participants