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

Two running instances of Mocha in Watch mode hang on first change detection #3404

Closed
4 tasks done
FL0RIANMEYER opened this issue Jun 1, 2018 · 4 comments
Closed
4 tasks done
Labels
area: usability concerning user experience or interface

Comments

@FL0RIANMEYER
Copy link

Prerequisites

  • Checked that your issue hasn't already been filed by cross-referencing issues with the faq label
  • Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
  • 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
  • Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with: node node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend avoiding the use of globally installed Mocha.

Description

Two running instances of Mocha in Watch mode hang on first change detection. Startup execution work as expected in both instances. Both instances just print 0 passing without failure prints. No Global instance of Mocha installed. Both instances in independent node_module directories.

Steps to Reproduce

package.json:

"scripts": {
    "test:devTest:service": "mocha -w compiled/devTest/test/unit/**/*.js -r mock-css-modules",
    "test:devTest:system": "mocha -w ../compiled/test/e2e/**/*.js",
}

shell:

npm run test:devTest:service
npm run test:devTest:system // in second terminal

Expected behavior: [What you expect to happen]
Execute both instances as expected

Actual behavior: [What actually happens]
Two running instances of Mocha in Watch mode hang on first change detection.
Both instances just print 0 passing without failure prints.
Reproduces how often: [What percentage of the time does it reproduce?]

Versions

  • The output of mocha --version and node node_modules/.bin/mocha --version:
    5.2.0
  • The output of node --version:
    v9.4.0
  • The version and architecture of your operating system:
    Windows 7 64
@outsideris outsideris added unconfirmed-bug area: usability concerning user experience or interface labels Jun 2, 2018
@outsideris
Copy link
Member

On macOS, it is fine. I should check it on Windows.

Could you provide mcve?

@outsideris outsideris added the status: waiting for author waiting on response from OP - more information needed label Jun 2, 2018
@FL0RIANMEYER
Copy link
Author

The reason seems to be the massive change injection of webpack-emit-all-plugin.

I think mocha can't handle a lot of changes in a short time. With two instances the problem occure just faster. Same with one instance but after the n-th compilation.

1. Just try setting up a slow test suite so that Mocha is killed after the first changes due to further changes.
2. Make many changes in a short time to the observed directory.

1.

it('t', async function(done) {
   this.timeout(2500);
   setTimeout(() => done, 2000);
});

2.

const fs = require('fs');

let i = 0;
setInterval(() => {
   fs.writeFile('./test.js', `const a = ${i++}`, () => {});
}, 10); // <- Adjust if too aggressive

setTimeout(() => process.exit(0), 3000);

or maybe

fs.writeFile(`./test${i}.js`, `const a = ${i++}`, () => {});

Solution

  • One solution could be to add a delay parameter to the -w argument -w 1000. But this could also create a flaky test behavior as the project grows. Or unnecessary long wait before testing.

  • An alternative could be to open an HTTP port to trigger events sent by other programs such as Webpack or Babel.

This problem can not be associated only with Webpack. The same behavior could also occur with babel or other compilers that produce many changes in the observed directory.

@plroebuck
Copy link
Contributor

Looks like you're generating files to be tested. Did you attempt to make use of --delay?

@juergba juergba removed the status: waiting for author waiting on response from OP - more information needed label Sep 9, 2019
@juergba
Copy link
Member

juergba commented Sep 9, 2019

The watch feature has been refactored completely using chokidar. If problem persists, please open a new issue. Closed by #3980.

@juergba juergba closed this as completed Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: usability concerning user experience or interface
Projects
None yet
Development

No branches or pull requests

4 participants