apiveritas
Version:
Lightweight CLI tool for consumer-driven API contract testing via JSON schema and payload comparisons.
35 lines (34 loc) • 1.49 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ApiVeritas = void 0;
const TestSuiteLoader_1 = require("./core/services/TestSuiteLoader");
const ApiCaller_1 = require("./core/services/ApiCaller");
const PayloadComparer_1 = require("./PayloadComparer");
const ConfigLoader_1 = require("./core/config/ConfigLoader");
const path_1 = __importDefault(require("path"));
class ApiVeritas {
constructor() {
const testFilePath = path_1.default.join(process.cwd(), 'tests', 'bookings.json');
const testSuite = TestSuiteLoader_1.TestSuiteLoader.loadSuite(testFilePath);
this.configLoader = new ConfigLoader_1.ConfigLoader();
this.config = this.configLoader.loadConfig();
this.caller = new ApiCaller_1.ApiCaller(testSuite, this.config);
this.comparer = new PayloadComparer_1.PayloadComparer(this.config);
}
async run(reportOnly = false) {
if (!reportOnly) {
await this.caller.callAll();
}
const latestFolders = this.comparer.getLatestTwoPayloadFolders();
if (!latestFolders) {
console.error('No payload folders found to compare.');
return;
}
const [previous, latest] = latestFolders;
this.comparer.compareFolders(previous, latest);
}
}
exports.ApiVeritas = ApiVeritas;