@apideck/portman
Version:
Port OpenAPI Spec to Postman Collection, with contract & variation tests included
22 lines • 1.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.testResponseTime = void 0;
var application_1 = require("../../application");
var testResponseTime = function (responseTime, pmOperation, config) {
var _a;
if (!(responseTime === null || responseTime === void 0 ? void 0 : responseTime.maxMs))
return pmOperation;
var split = (_a = config === null || config === void 0 ? void 0 : config.separatorSymbol) !== null && _a !== void 0 ? _a : '::';
var maxMs = responseTime.maxMs;
var pmTest = [
"// Validate response time \n",
"pm.test(\"[".concat(pmOperation.method.toUpperCase(), "]").concat(split).concat(pmOperation.path),
" - Response time is less than ".concat(maxMs, "ms\", function () {\n"),
" pm.expect(pm.response.responseTime).to.be.below(".concat(maxMs, ");\n"),
"});\n"
].join('');
(0, application_1.writeOperationTestScript)(pmOperation, pmTest);
return pmOperation;
};
exports.testResponseTime = testResponseTime;
//# sourceMappingURL=testResponseTime.js.map