Use this file to discover all available pages before exploring further.
EdgeSpark has no local development server, which shapes how testing works. Unit tests run locally against pure logic. Integration tests run against a deployed environment.
Unit tests are best for pure functions — logic that does not depend on the platform client. Extract this logic from your route handlers and test it in isolation.
server/src/lib/posts.ts
export function formatPost(post: { title: string; createdAt: number }) { return { ...post, formattedDate: new Date(post.createdAt * 1000).toISOString(), };}export function validatePostInput(body: unknown): { title: string; content?: string } { if (typeof body !== "object" || body === null) { throw new Error("Body must be an object"); } const { title } = body as Record<string, unknown>; if (typeof title !== "string" || title.trim().length === 0) { throw new Error("title is required"); } return { title: (body as any).title, content: (body as any).content };}
server/src/lib/posts.test.ts
import { describe, it, expect } from "vitest";import { formatPost, validatePostInput } from "./posts";describe("formatPost", () => { it("formats the date as ISO string", () => { const result = formatPost({ title: "Hello", createdAt: 1700000000 }); expect(result.formattedDate).toBe("2023-11-14T22:13:20.000Z"); });});describe("validatePostInput", () => { it("returns validated input for valid body", () => { const result = validatePostInput({ title: "Hello" }); expect(result.title).toBe("Hello"); }); it("throws if title is missing", () => { expect(() => validatePostInput({ content: "no title" })).toThrow("title is required"); }); it("throws if body is not an object", () => { expect(() => validatePostInput("string")).toThrow("Body must be an object"); });});
BASE=https://my-app.edgespark.app# Public routecurl "$BASE/api/public/feed"# Create a post (requires session)curl -X POST "$BASE/api/posts" \ -H "Cookie: better-auth.session_token=$SESSION_TOKEN" \ -H "Content-Type: application/json" \ -d '{"title": "Integration test post"}'# Get the post backcurl "$BASE/api/posts/1" \ -H "Cookie: better-auth.session_token=$SESSION_TOKEN"
Protected routes return 401 without a session cookie
Public routes return data without a session cookie
Webhook routes accept requests without auth
Error cases return consistent error shapes
Database reads and writes work as expected
File uploads and presigned URL flows work end to end
Public staging environments are coming soon. Today, integration testing happens against the current deployed project environment, so prefer edgespark deploy --dry-run before a real deploy and keep deployed test changes small.