Skip to content

Conversation

@wlldrygla
Copy link

I fixed issue #4416, creating a new method: GlobalReporter.waitResultForAllSuites

What I did was:

  1. On the DefaultRunner.runConcurrent, I count the modules where are running (test suites/files)
  2. Pass this number to DefaultRunner.reportResults
  3. DefaultRunner.reportResults call GlobalReporter.waitResultForAllSuites if received totalSuitesExpected
  4. GlobalReporter.waitResultForAllSuites checks if GlobalReporter.totalSuites length is equal to totalSuitesExpected
    4.1 if is different, checks each 500ms again, to check if a result arrived and the GlobalReporter.totalSuites length is equal to totalSuitesExpected
    4.2 I added a timeout of 30s to this, to await results arrive
  5. When condition is met or timeouts, the flow keep going and call the GlobalReporter.create with available suites results

I tested this during several days, never had a missing result, but, I had logs to prove that would have missing results, I will let them bellow, but, what I saw was, GlobalReporter.addTestSuiteResults been call (triggered by the event emited on worker-task) while GlobalReporter.save was already running (and it uses the GlobalReporter.globalResults builded before, so the new suite result isnt used to generate files).
I also tested running tests alone, without use DefaultRunner.runConcurrent and it keep working as expected

NORMAL CASE:

[global-reports.js] GlobalReporter.save - starting
[global-reports.js] GlobalReporter.save - expected suites: 77
[global-reports.js] GlobalReporter.save - total suites until now: 77
[global-reports.js] GlobalReporter.waitResultForAllSuites - if to check suites total
[global-reports.js] GlobalReporter.waitResultForAllSuites - condition met 77  =  77
[global-reports.js] GlobalReporter.save - RETURN
 Wrote HTML report file to: NIGHTWATCH-REPO-PATH/reports/nightwatch-html-report/index.html

RESULT ARRIVING WHILE SAVE RUNNING

[global-reports.js] GlobalReporter.save - starting
[global-reports.js] GlobalReporter.save - expected suites: 77
[global-reports.js] GlobalReporter.save - total suites results until now: 76
[global-reports.js] GlobalReporter.waitResultForAllSuites - inside if to check suites total
[global-reports.js] GlobalReporter.waitResultForAllSuites - condition NOT met 76  !=  77
[worker-task.js] WorkerTask.runWorkerTask: port2.onmessage “testsuite_finished” for suite: chrome: 
tests/TESTCASE_NAME_77.ts
[global-reports.js] GlobalReporter.setupChildProcessListener: on message, suitename: chrome: tests/TESTCASE_NAME_77.ts
[global-reports.js] GlobalReporter.addTestSuiteResults start
[global-reports.js] GlobalReporter.addTestSuiteResults - new total suites:  77
[global-reports.js] GlobalReporter.waitResultForAllSuites - condition met 77  =  77
[global-reports.js] GlobalReporter.save - RETURN
 Wrote HTML report file to: NIGHTWATCH-REPO-PATH/reports/nightwatch-html-report/index.html

_ I omitted file names because I runned using a private repository_

Thanks in advance for your contribution. Please follow the below steps in submitting a pull request, as it will help us with reviewing it quicker.

  • Before marking your PR for review, please test and verify your changes by making appropriate modifications to any of the Nightwatch example tests (present in examples/tests directory of the project) and running them. ecosia.js and duckDuckGo.js are good examples to work with.
  • Create a new branch from master (e.g. features/my-new-feature or issue/123-my-bugfix);
  • If you're fixing a bug also create an issue if one doesn't exist yet;
  • If it's a new feature explain why do you think it's necessary. Please check with the maintainers beforehand to make sure it is something that we will accept. Usually we only accept new features if we feel that they will benefit the entire community;
  • Please avoid sending PRs which contain drastic or low level changes. If you are certain that the changes are needed, please discuss them beforehand and indicate what the impact will be;
  • If your change is based on existing functionality please consider refactoring first. Pull requests that duplicate code will most likely be ignored;
  • Do not include changes that are not related to the issue at hand;
  • Follow the same coding style with regards to spaces, semicolons, variable naming etc.;
  • Always add unit tests - PRs without tests are most of the times ignored.

@CLAassistant
Copy link

CLAassistant commented Oct 22, 2025

CLA assistant check
All committers have signed the CLA.

@wlldrygla wlldrygla force-pushed the issue/4416-missing-reports-async-issue branch from 4a19a42 to a51684a Compare October 22, 2025 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants