Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/bun-typecheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ jobs:
- name: Install dependencies
run: bun i

- name: Build the project
run: bun run build

- name: Run type check
run: bunx tsc --noEmit
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"@biomejs/biome": "^1.8.3",
"@types/bun": "latest",
"@types/react": "18.3.4",
"next": "^14.2.5",
"redaxios": "^0.5.1"
"ky": "^1.8.1",
"next": "^14.2.5"
},
"peerDependencies": {
"typescript": "^5.0.0"
Expand Down
10 changes: 5 additions & 5 deletions tests/fixtures/get-test-server.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { afterEach } from "bun:test"
import { tmpdir } from "node:os"
import defaultAxios from "redaxios"
import ky from "ky"
import { startServer } from "./start-server"

interface TestFixture {
url: string
server: any
axios: typeof defaultAxios
ky: typeof ky
}

export const getTestServer = async (): Promise<TestFixture> => {
Expand All @@ -20,8 +20,8 @@ export const getTestServer = async (): Promise<TestFixture> => {
})

const url = `http://127.0.0.1:${port}`
const axios = defaultAxios.create({
baseURL: url,
const kyInstance = ky.create({
prefixUrl: url,
})

afterEach(async () => {
Expand All @@ -32,6 +32,6 @@ export const getTestServer = async (): Promise<TestFixture> => {
return {
url,
server,
axios,
ky: kyInstance,
}
}
7 changes: 4 additions & 3 deletions tests/routes/health.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { it, expect } from "bun:test"
import { getTestServer } from "tests/fixtures/get-test-server"

it("GET /health should return ok", async () => {
const { axios } = await getTestServer()
const res = await axios.get("/health")
const { ky } = await getTestServer()
const res = await ky.get("health")
expect(res.status).toBe(200)
expect(res.data).toEqual({ ok: true })
const data = await res.json()
expect(data).toEqual({ ok: true })
})
14 changes: 9 additions & 5 deletions tests/routes/things/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ import { getTestServer } from "tests/fixtures/get-test-server"
import { test, expect } from "bun:test"

test("create a thing", async () => {
const { axios } = await getTestServer()
const { ky } = await getTestServer()

axios.post("/things/create", {
name: "Thing1",
description: "Thing1 Description",
ky.post("things/create", {
json: {
name: "Thing1",
description: "Thing1 Description",
},
})

const { data } = await axios.get("/things/list")
const data = await ky
.get("things/list")
.json<{ things: { name: string; description: string }[] }>()

expect(data.things).toHaveLength(1)
})