How to Aggregate and View Code Coverage for All Custom Node Modules in a Single Execution

I’m working with multiple custom Node-RED modules, and I want to execute and view the test case results for all my custom modules while generating a consolidated code coverage report in a single execution.

Folder Structure and Context
Here is an example of my folder structure for one of the custom modules:


Below attached the package.json for reference

{
  "name": "node-red-contrib-create-jwt-token",
  "version": "1.0.0",
  "description": "",
  "main": "create-jwt-token.js",
  "keywords": [
    "node-red"
  ],
  "node-red": {
    "nodes": {
      "create-jwt-token": "create-jwt-token.js"
    }
  }, 
  "nyc": {
  "reporter": ["text", "html"],
  "report-dir": "./coverage"
},
   "scripts": {
    "test": "nyc mocha test/create-jwt-token_spec.js"
  },

  
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "chai": "^5.1.2",
    "mocha": "^11.0.1",
    "node-red": "^4.0.7",
    "node-red-node-test-helper": "^0.3.4",
    "sinon": "^19.0.2",
    "sinon-chai": "^4.0.0"
  }
}

Goal
I want to:

  • Run tests for all custom modules at once.
  • Generate a unified code coverage report for all these modules.
  • Export or view the test results for each custom module in one go.

Challenges

  • Currently, I can run tests and view coverage for individual modules using nyc mocha, but I’m unsure how to configure this for multiple custom modules collectively in a way that provides a combined coverage report.

Questions

  • What’s the best approach to aggregate tests and generate a combined coverage report for multiple Node-RED custom modules?
  • Are there specific tools or configurations in nyc or other test frameworks that can facilitate this?
  • Any examples or recommendations for managing consolidated test execution and reporting in a Node-RED custom module environment?
  • Looking forward to your insights!

Thank you in advance for your guidance.