Closed rizwanansari367 closed 1 year ago
There is currently limited support for throwing exception in scenario execution. I may make a few patches when I get a chance. If the exception is thrown from your scenario callbacks (e.g., action
, back
etc.), I recommend adding try-catch clauses in your scenario callbacks. An alternative is to initiate a memlab run via the bash command (via the node.js child process API).
Hi, I have written a script that will execute all scenario files and store the result in separate directory. But if one of the scenario file failed to execute then it stopped the execution of the remaining scenario file also. I am handling the exception in my main script file with try catch around run, but not working. Below is the main script file.
const { run } = require('@memlab/api'); const fs = require('fs-extra'); const path = require('path');
const scenariosDir = 'D:/Puppeteer'; const workDir = 'D:/Puppeteer/Result';
// Read all scenario files from the Scenarios directory const scenarioFiles = fs.readdirSync(scenariosDir).filter(file => file.endsWith('.js'));
(async function () { // Ensure the working directory exists fs.mkdirsSync(workDir);
// Iterate through all scenario files and run them for (const scenarioFile of scenarioFiles) { const scenario = require(path.join(scenariosDir, scenarioFile)); const scenarioResultDir = path.join(workDir, path.basename(scenarioFile, '.js'));
}
})();