blob: c1f5f644654cd58063cc4d11d3064871d54d1606 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
import { type Server } from "bun";
import { expect, test, beforeAll, afterAll } from "bun:test";
import app from "../src/index";
const port = 33000;
const base = `http://localhost:${port}/`;
let server: Server;
beforeAll(async function () {
server = Bun.serve(Object.assign({}, app, { port }));
});
afterAll(function () {
server.stop();
});
test("/ returns 200", async function () {
const res = await fetch(base);
expect(res.status).toBe(200);
});
test("/asdf returns 404", async function () {
const res = await fetch(`${base}asdf`);
expect(res.status).toBe(404);
});
|