response.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import { TestResponse } from "@hoppscotch/js-sandbox";
  2. import { Method } from "axios";
  3. import { ExpectResult } from "../types/response";
  4. import { HoppEnvs } from "../types/request";
  5. /**
  6. * Defines column headers for table stream used to write table
  7. * data on stdout.
  8. * @property {string} path Path of request within collection file.
  9. * @property {string} endpoint Endpoint from response config.url.
  10. * @property {Method} method Method from response headers.
  11. * @property {string} statusCode Template string concating status & statusText.
  12. */
  13. export interface TableResponse {
  14. endpoint: string;
  15. method: Method;
  16. statusCode: string;
  17. }
  18. /**
  19. * Describes additional details of HTTP response returned from
  20. * requestRunner.
  21. * @property {string} path Path of request within collection file.
  22. * @property {string} endpoint Endpoint from response config.url.
  23. * @property {Method} method Method from HTTP response headers.
  24. * @property {string} statusText HTTP response status text.
  25. */
  26. export interface RequestRunnerResponse extends TestResponse {
  27. endpoint: string;
  28. method: Method;
  29. statusText: string;
  30. duration: number;
  31. }
  32. /**
  33. * Describes test script details.
  34. * @property {string} name Request name within collection.
  35. * @property {string} testScript Stringified hoppscotch testScript, used while
  36. * running testRunner.
  37. * @property {TestResponse} response Response structure for test script runner.
  38. */
  39. export interface TestScriptParams {
  40. testScript: string;
  41. response: TestResponse;
  42. envs: HoppEnvs;
  43. }
  44. /**
  45. * Describe properties of test-report generated from test-runner.
  46. * @property {string} descriptor Test description.
  47. * @property {ExpectResult[]} expectResults Expected results for each
  48. * test-case.
  49. * @property {number} failed Total failed test-cases.
  50. * @property {number} passed Total passed test-cases;
  51. */
  52. export interface TestReport {
  53. descriptor: string;
  54. expectResults: ExpectResult[];
  55. failed: number;
  56. passed: number;
  57. }
  58. /**
  59. * Describes error pair for failed HTTP requests.
  60. * @example { 501: "Request Not Supported" }
  61. */
  62. export interface ResponseErrorPair {
  63. [key: number]: string;
  64. }