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

Mocha fails to reload watched files #4016

Open
geigerzaehler opened this issue Sep 13, 2019 · 6 comments
Open

Mocha fails to reload watched files #4016

geigerzaehler opened this issue Sep 13, 2019 · 6 comments
Labels
area: node.js command-line-or-Node.js-specific status: accepting prs Mocha can use your help with this one! type: bug a defect, confirmed by a maintainer

Comments

@geigerzaehler
Copy link
Contributor

Under certain circumstances Mocha fails to reload source files in watch mode. Specifically, if a file is watched and modified but only required by a file that is not watched then the modified file is not reloaded and the change is not visible to the test suite.

This issue can be addressed by adding the unwatched files to --watch-files

Steps to Reproduce

Create the following three files

// lib-a/index.js
module.exports = true
// lib-b/index.js
module.exports = require('../lib-a')
// test/main.js
const assert = require('assert')
const value = require('../lib-b')
it('works', function () {
  assert(value)
})

Now run

mocha --watch --watch-files lib-a,test

The test suite passes.

Now modify lib-a/index.js so that the exported value is false. This will retrigger the tests but they will still succeed.

If lib-b is add to the --watch-files list then the modification results in a test failure.

@solaris765

This comment was marked as resolved.

@geigerzaehler

This comment was marked as resolved.

@solaris765

This comment was marked as resolved.

@solaris765

This comment was marked as resolved.

@geigerzaehler

This comment was marked as resolved.

@JoshuaKGoldberg
Copy link
Member

I can confirm this is still an issue in Mocha 10.2.0. I posted a standalone repro branch here: https://github.com/JoshuaKGoldberg/repros/tree/mocha-watchfile-updates

@JoshuaKGoldberg JoshuaKGoldberg added type: bug a defect, confirmed by a maintainer status: accepting prs Mocha can use your help with this one! area: node.js command-line-or-Node.js-specific and removed unconfirmed-bug labels Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: node.js command-line-or-Node.js-specific status: accepting prs Mocha can use your help with this one! type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

No branches or pull requests

3 participants