Use `vitest` for backend tests: - `bench` script now uses [vitest's `bench`](https://vitest.dev/api/#bench) - e2e test fails with same error happening now with jest:`data-testid` attribute not present. vitest left, jest right <img width="1264" height="603" alt="image" src="https://github.com/user-attachments/assets/56fc43a6-e143-4208-bf14-7e016aae7fa9" />
56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
import axios from "axios";
|
|
import MockAdapter from "axios-mock-adapter";
|
|
import { bench, describe, vi } from "vitest";
|
|
|
|
import gist from "../../api-renamed/gist.js";
|
|
|
|
const gist_data = {
|
|
data: {
|
|
viewer: {
|
|
gist: {
|
|
description:
|
|
"List of countries and territories in English and Spanish: name, continent, capital, dial code, country codes, TLD, and area in sq km. Lista de países y territorios en Inglés y Español: nombre, continente, capital, código de teléfono, códigos de país, dominio y área en km cuadrados. Updated 2023",
|
|
owner: {
|
|
login: "Yizack",
|
|
},
|
|
stargazerCount: 33,
|
|
forks: {
|
|
totalCount: 11,
|
|
},
|
|
files: [
|
|
{
|
|
name: "countries.json",
|
|
language: {
|
|
name: "JSON",
|
|
},
|
|
size: 85858,
|
|
},
|
|
],
|
|
},
|
|
},
|
|
},
|
|
};
|
|
|
|
const mock = new MockAdapter(axios);
|
|
mock.onPost("https://api.github.com/graphql").reply(200, gist_data);
|
|
|
|
describe("test /api/gist", () => {
|
|
bench(
|
|
"base",
|
|
async () => {
|
|
const req = {
|
|
query: {
|
|
id: "bbfce31e0217a3689c8d961a356cb10d",
|
|
},
|
|
};
|
|
const res = {
|
|
setHeader: vi.fn(),
|
|
send: vi.fn(),
|
|
};
|
|
|
|
await gist(req, res);
|
|
},
|
|
{ warmupIterations: 50 },
|
|
);
|
|
});
|