Skip to main content
Module

x/fastro/server/server_test.tsx

Fast and simple web application framework for deno
Go to Latest
File
import { HttpRequest, HttpResponse } from "../types.d.ts";import { assertEquals } from "./deps.ts";import { fastro } from "./server.ts";
const host = "http://localhost:9000";
Deno.test({ permissions: { net: true } }, async function jsx() { const app = fastro(); app.get( "/", (req: HttpRequest, res: HttpResponse) => res.status(200).jsx(<h1>Hello jsx</h1>), ); app.post("/", () => <h1>Hello jsx</h1>); const server = app.serve();
let response = await fetch(host, { method: "GET" }); // console.log("await response.text()", await response.text()); assertEquals(await response.text(), `<h1>Hello jsx</h1>`);
response = await fetch(host, { method: "POST" }); console.log("await response.text()", await response.text()); // assertEquals(await response.text(), `<h1>Hello jsx</h1>`);
app.close(); await server;});