Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
import { RequestMetrics } from "../../../types/response";
import { getRequestMetrics } from "../../../utils/request";
describe("getRequestMetrics", () => {
test("With empty errors.", () => {
expect(getRequestMetrics([], 1)).toMatchObject(<RequestMetrics>{
requests: { failed: 0, passed: 1 },
});
});
test("With non-empty errors.", () => {
expect(
getRequestMetrics(
[
{ code: "REQUEST_ERROR", data: {} },
{ code: "PARSING_ERROR", data: {} },
],
1
)
).toMatchObject(<RequestMetrics>{
requests: { failed: 1, passed: 0 },
});
});
});