magento2-cypress-testing-suite
                                
                                
                                
                                    magento2-cypress-testing-suite copied to clipboard
                            
                            
                            
                        Dependency of node "module" can not be used with "require()"
Describe the bug
The PR https://github.com/elgentos/magento2-cypress-testing-suite/pull/98 breaks the config with
Your configFile is invalid: ...magento2-cypress-testing-suite/cypress.config.js
It threw an error when required, check the stack trace below:
Error [ERR_REQUIRE_ESM]: require() of ES Module ...magento2-cypress-testing-suite/node_modules/del/index.js from ...magento2-cypress-testing-suite/cypress.config.js not supported.
Instead change the require of index.js in /Volumes/CaseSensitive/Workspace/php-sites/mos-hyva-245/magento2-cypress-testing-suite/cypress.config.js to a dynamic import() which is available in all CommonJS modules.
The problem is that [email protected] is a node module, not a library (see "type": "module", in the del package.json).
This means it needs to be used with import.
The most simple fix is to use const del = import('del');
However, I suggest removing the dependency, since deleting folders and files is a trivial problem - node offers all that is needed out of the box (since fs is already imported):
return fs.rmdirSync(results.video, {recursive: true})
To Reproduce
git checkout main
git pull
npm ci
npx cypress run
Expected behavior Cypress runs tests
Screenshots

The same PR also introduced additional issues by using _ which is not defined.