UNPKG

@aibulat/funtest

Version:

Using supertest to make tests for some publicly available REST APIs

18 lines (17 loc) 589 B
// import { jest, describe, expect, test } from "@jest/globals"; import request from "supertest"; import { stdChecks, checkProps } from "./utils.js"; import samples from "./sample/ipinfo.js"; const url = "https://ipinfo.io"; const req = request(url); test(`connect ${url}`, async () => { const path = "/"; const response = await req.get(path); expect(response.status).toBe(200); }); test("get /8.8.8.8", async () => { const path = "/8.8.8.8"; const response = await req.get(path); stdChecks(response); checkProps(response.body, Object.keys(samples.reply)); });