Zaista / cypress-mongodb

Cypress MongoDB plugin
MIT License
17 stars 8 forks source link

Error: Webpack Compilation Error when we set const mongo = require('cypress-mongodb'); mongo.addCommands(); #22

Closed matifniaz closed 1 year ago

matifniaz commented 2 years ago

As per your provided configuration, When we added the below lines and run our spec file we got this error.

In your cypress/support/e2e.js add the following: const mongo = require('cypress-mongodb'); mongo.addCommands();

Spec file snapshot attahced for refernece.

image

Error snapshot is attached for reference. image Pakage,json { "name": "cypress", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { "cypress": "^10.9.0", "cypress-downloadfile": "^1.2.3", "npm-check-updates": "^16.3.11" }, "devDependencies": { "cypress-file-upload": "^5.0.8", "cypress-mochawesome-reporter": "^3.2.3", "cypress-xpath": "^2.0.1", "multiple-cucumber-html-reporter": "^3.0.1" } }

chris-mclennan commented 2 years ago

I too have this same problem. When I comment out the two commands matifniaz mentions, the error goes away and cypress will run tests as long as they do not reference one of the cypress-mongodb commands.
image

Zaista commented 1 year ago

Thanks for raising the issue, will take a look over the weekend.

chris-mclennan commented 1 year ago

If you think of any way to get around it in the mean time, please share. I cant use Cypress without turning off a lot of tests and cypress-mongodb

chris-mclennan commented 1 year ago

I found a workaround by renaming the node_modules/@aws-sdk folder. After that I could run tests

chris-mclennan commented 1 year ago

I found another temporary workaround by removing all references to @aws-sdk from package-lock.json and running npm install again.

PabloRamirezDev commented 1 year ago

I'm having the same issue. In my case, I'm using typescript with cypress 10.11.0

wilson208 commented 1 year ago

For anyone else running into this, in latest mongodb release 4.11.0 they made aws-sdk dependencies optional.

To fix this error you can update to latest mongodb version and re-install dependencies with yarn install --ignore-optional. You may need to delete node_modules and yarn.lock for this to work.

raialmeida commented 1 year ago

Hi, I'm having the same problem.

dgoerdes commented 1 year ago

As @wilson208 wrote, it is the mongodb dependency which causes the issue. I downgraded to version 4.10.0, and it works.

Zaista commented 1 year ago

Should be fixed with the latest version I just published, but I'm not quite sure tbh, this was a tricky one. Please let me know if you encounter more issues