bigbite / wp-cypress

WordPress end to end testing with Cypress.io.
MIT License
86 stars 19 forks source link

fix: replace fs.watch with chokidar #75

Closed ampersarnie closed 3 years ago

ampersarnie commented 3 years ago

Description

fs.watch has presented numerous compatibility issues that cause failures in some environments and machines. This seems to most prominently affect Linux distros but not providing Node with the adequate means of recursively watching directories. As a result we need to replace the watch features with something more compatible. Chokidar was chosen as it has a proven record since being installed in numerous JS based systems, such as VSCode and webpack.

Reported Error

Opening Cypress...
The function exported by the plugins file threw an error.

We invoked the function exported by `/home/circleci/project/cypress/plugins/index.js`, but it threw an error.

 TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js
    at Object.watch (fs.js:1521:11)
    at watchDir (/home/circleci/project/node_modules/@bigbite/wp-cypress/lib/utils/watchDir.js:6:6)
    at module.exports (/home/circleci/project/node_modules/@bigbite/wp-cypress/lib/cypress-plugin/index.js:36:5)
    at module.exports (/home/circleci/project/cypress/plugins/index.js:22:40)
    at /home/circleci/.cache/Cypress/7.7.0/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:90:12
    at tryCatcher (/home/circleci/.cache/Cypress/7.7.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/util.js:16:23)
    at Function.Promise.attempt.Promise.try (/home/circleci/.cache/Cypress/7.7.0/Cypress/resources/app/packages/server/node_modules/bluebird/js/release/method.js:39:29)
    at load (/home/circleci/.cache/Cypress/7.7.0/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:87:7)
    at EventEmitter.<anonymous> (/home/circleci/.cache/Cypress/7.7.0/Cypress/resources/app/packages/server/lib/plugins/child/run_plugins.js:198:5)
    at EventEmitter.emit (events.js:315:20)
    at process.<anonymous> (/home/circleci/.cache/Cypress/7.7.0/Cypress/resources/app/packages/server/lib/plugins/util.js:19:22)
    at process.emit (events.js:315:20)
    at emit (internal/child_process.js:903:12)
    at processTicksAndRejections (internal/process/task_queues.js:81:21)
error Command failed with exit code 1.

Change Log

Screenshots/Videos

If PR includes visual changes, please include a screenshot (or short video if applicable).

Types of changes (if applicable):

Checklist (if applicable):