UNPKG

fluentrest-ts

Version:

A lightweight, fluent TypeScript API testing library inspired by Java's RestAssured. Built on top of Axios, JSONPath, and Joi for powerful request handling and response validation.

16 lines (15 loc) 573 B
import { AxiosRequestConfig, AxiosResponse } from "axios"; import Joi from "joi"; export interface ResponseValidator { error?: any; wasFailure(): boolean; getResponse(): AxiosResponse; getRequestConfig(): AxiosRequestConfig; thenExpectStatus(status: number): this; thenExpectBody(path: string, expected: any): this; thenExpectBodyContains(fragment: object): this; thenValidateBody(schema: Joi.Schema): this; thenExpectHeader(key: string, value: string): this; thenExtract(path: string): any; catchAndLog(fn: () => void): this; }