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" />
55 lines
1.1 KiB
JavaScript
55 lines
1.1 KiB
JavaScript
import axios from "axios";
|
|
import MockAdapter from "axios-mock-adapter";
|
|
import { bench, describe, vi } from "vitest";
|
|
|
|
import pin from "../../api-renamed/pin.js";
|
|
|
|
const data_repo = {
|
|
repository: {
|
|
username: "anuraghazra",
|
|
name: "convoychat",
|
|
stargazers: {
|
|
totalCount: 38000,
|
|
},
|
|
description: "Help us take over the world! React + TS + GraphQL Chat App",
|
|
primaryLanguage: {
|
|
color: "#2b7489",
|
|
id: "MDg6TGFuZ3VhZ2UyODc=",
|
|
name: "TypeScript",
|
|
},
|
|
forkCount: 100,
|
|
isTemplate: false,
|
|
},
|
|
};
|
|
|
|
const data_user = {
|
|
data: {
|
|
user: { repository: data_repo.repository },
|
|
organization: null,
|
|
},
|
|
};
|
|
|
|
const mock = new MockAdapter(axios);
|
|
mock.onPost("https://api.github.com/graphql").reply(200, data_user);
|
|
|
|
describe("/api/pin", () => {
|
|
bench(
|
|
"base",
|
|
async () => {
|
|
const req = {
|
|
query: {
|
|
username: "anuraghazra",
|
|
repo: "convoychat",
|
|
},
|
|
};
|
|
const res = {
|
|
setHeader: vi.fn(),
|
|
send: vi.fn(),
|
|
};
|
|
|
|
await pin(req, res);
|
|
},
|
|
{ warmupIterations: 50 },
|
|
);
|
|
});
|