import { MockServer } from "https://deno.land/x/alephjs@1.0.0-alpha.78.1/server/mock.ts";
The MockServer class to create a minimal server for integration testing.
Limits:
- importing css is NOT allowed:
import "./style.css"
- custom loader is NOT supported, like
import "./component.vue"
Examples
Example 1
Example 1
import { assertEquals } from "std/testing/asserts.ts";
import { MockServer } from "aleph/server/mock.ts";
Deno.test(async () => {
const api = new MockServer({
routes: "./routes/**\/*.ts"
});
const res = await api.fetch("/users?page=1&limit=10");
assertEquals(res.status, 200);
assertEquals((await res.json()).length, 10);
})
Methods
fetch(input: string, init?: RequestInit)