From b96c3bd3e14831e936b4dd2962bb26cbc493d047 Mon Sep 17 00:00:00 2001 From: Florin Barbu Date: Fri, 13 Oct 2023 17:32:28 +0300 Subject: [PATCH] chore: disable paralles runs locally (#1662) * disable paralles runs locally * add logs * add readme info about local execution --- packages/tests/.mocharc.json | 2 +- packages/tests/README.md | 1 + packages/tests/src/run-tests.js | 36 ++++++++++++++++++++------------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/packages/tests/.mocharc.json b/packages/tests/.mocharc.json index 72164c409b..06fc1304b9 100644 --- a/packages/tests/.mocharc.json +++ b/packages/tests/.mocharc.json @@ -8,6 +8,6 @@ ], "exit": true, "retries": 4, - "parallel": true, + "parallel": false, "jobs": 6 } diff --git a/packages/tests/README.md b/packages/tests/README.md index 9a42689812..99ef6d64fc 100644 --- a/packages/tests/README.md +++ b/packages/tests/README.md @@ -40,6 +40,7 @@ Therefore, you need to have `docker` installed on your machine to run the tests. WAKUNODE_IMAGE=image-name npm run test:node ``` +- Locally, tests are executed serially, allowing the use of **.only** for focused testing. If you wish to run all tests locally and expedite the process, you can enable parallel execution in the Mocha configuration. # Running tests in the CI diff --git a/packages/tests/src/run-tests.js b/packages/tests/src/run-tests.js index 4d01ddfe1e..6b7c9cc78f 100644 --- a/packages/tests/src/run-tests.js +++ b/packages/tests/src/run-tests.js @@ -15,21 +15,29 @@ async function main() { console.log("Image pulled"); } + const mochaArgs = [ + "mocha", + "--require", + "ts-node/register", + "--project", + "./tsconfig.dev.json", + ...process.argv.slice(2) + ]; + + // If in CI, add --parallel + if (process.env.CI) { + mochaArgs.push("--parallel"); + console.log("Running tests in parallel"); + } else { + console.log( + "Running tests serially. To enable parallel execution update mocha config" + ); + } + // Run mocha tests - const mocha = spawn( - "npx", - [ - "mocha", - "--require", - "ts-node/register", - "--project", - "./tsconfig.dev.json", - ...process.argv.slice(2) - ], - { - stdio: "inherit" - } - ); + const mocha = spawn("npx", mochaArgs, { + stdio: "inherit" + }); mocha.on("error", (error) => { console.log(`Error running mocha tests: ${error.message}`);