in lib/apiScenario/postmanCollectionGenerator.ts [200:260]
private async doRun() {
await this.swaggerAnalyzer.initialize();
for (const it of this.scenarioDef.requiredVariables) {
if (this.opt.env[it] === undefined) {
throw new Error(
`Missing required variable '${it}', please set variable values in env.json.`
);
}
}
this.opt.runId = this.opt.runId || generateRunId();
if (this.opt.markdown) {
const reportExportPath = path.resolve(
this.opt.outputFolder,
`${defaultNewmanDir(this.scenarioDef.name, this.opt.runId!)}`
);
await this.fileLoader.writeFile(
path.join(reportExportPath, "report.md"),
generateMarkdownReportHeader()
);
}
await this.generateCollection();
if (this.opt.generateCollection) {
await this.writeCollectionToJson(this.scenarioDef.name, this.collection, this.environment);
}
if (this.opt.runCollection) {
try {
for (let i = 0; i < this.scenarioDef.scenarios.length; i++) {
const scenario = this.scenarioDef.scenarios[i];
const foldersToRun = [];
if (
i == 0 &&
this.collection.items.find((item) => item.name === PREPARE_FOLDER, this.collection)
) {
foldersToRun.push(PREPARE_FOLDER);
}
foldersToRun.push(scenario.scenario);
const reportExportPath = path.resolve(
this.opt.outputFolder,
`${defaultNewmanReport(this.scenarioDef.name, this.opt.runId!, scenario.scenario)}`
);
const summary = await this.doRunCollection({
collection: this.collection,
environment: this.environment,
folder: foldersToRun,
reporters: "cli",
});
await this.postRun(scenario, reportExportPath, summary.environment, summary);
this.environment = summary.environment;
}
} catch (err) {
logger.error(`Error in running collection: ${err}`);
}
}
}