-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
fix: Updating spec watcher to detect directory events #20962
Conversation
Thanks for taking the time to open a PR!
|
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
// We respond to all changes to the project's filesystem when | ||
// files or directories are added and removed that are not explicitly | ||
// ignored by config | ||
this._specWatcher = chokidar.watch('.', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 9.x we had integration/component folders defined in config to better scope what we're watching, but no longer. I still worry that this may be too broad/expensive, but debouncing the handler will limit the amount of thrash that can result. We could add more explicit ignored dirs (node_modules)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So are we saying that providing the specPattern
here definitely does not work properly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my testing, yes, it does not work correctly when files are introduced with or removed alongside parent directories. No 'add'/'unlink' events for those files get emitted in that case. This could very well be a bug within chokidar, I need to dig into its implementation more fully to figure out why it's behaving this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, it looks like chokidar v4 is dropping globbing entirely: paulmillr/chokidar#1195, so this might be the best approach, to watch the directory and handle matching on our side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes are very clean & easy to follow, thank you! I don't know enough about Cypress to understand the effects of more broadly watching file changes, so I will leave that part of the review up to others :)
…ce duration to match develop. Explicitly ignoring node_modules for watcher.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, as I mentioned I think we'd gain a lot by cleaning up the spec management layer in general but getting it working & tested is a great first step!
…1206-cloud * tgriesser/fix/UNIFY-1206-git: add ensureDir fix test fix: Updating spec watcher to detect directory events (#20962) chore(launchpad): fix launchpad e2e tests on windows refactor: allow ts-node to be scoped (#20786)
We use chokidar to detect changes to a project's filesystem and reflect changes to specs (new specs / removed specs) in the Cypress app. However, chokidar will not emit file add events for files that are added alongside a new directory; the converse is also true for removed file events during the removal of a parent directory. We are also limiting what we watch to files that match the spec pattern; however, that does not include directories that may be a partial match.
I updated the chokidar watcher to listen for changes more broadly. I also updated the debounce duration on our handler so that sequential filesystem events do not trigger our spec detection more often than necessary (it was defaulting to a debounce timeout of 0 previously).
User facing changelog
Additional details
How has the user experience changed?
PR Tasks
cypress-documentation
?type definitions
?cypress.schema.json
?