kewp
Testing API server
when I wrap in Deno.test it fails:
Deno.test("It should respond with 'Hello, World!'", async () => {
const response = await fetch("http://localhost:8000/");
const body = await response.text();
assertEquals(body, "Hello, World!");
});
but when I just run it without it works!
const response = await fetch("http://localhost:8000/");
const body = await response.text();
assertEquals(body, "Hello, World!");
7 replies
Testing API server
i keep getting a connection refused error:
deno test --allow-net --allow-run test_server.ts
Check file:///Users/karl/fcache/test_server.ts
starting server
Listening on http://localhost:8000/
running 1 test from ./test_server.ts
It should respond with 'Hello, World!' ... FAILED (13ms)
ERRORS
It should respond with 'Hello, World!' => ./test_server.ts:25:6
error: TypeError: error sending request for url (http://localhost:8000/): error trying to connect: tcp connect error: Connection refused (os error 61)
const response = await fetch("http://localhost:8000/");
^
at async mainFetch (ext:deno_fetch/26_fetch.js:170:12)
at async fetch (ext:deno_fetch/26_fetch.js:391:7)
at async file:///Users/karl/fcache/test_server.ts:26:20
FAILURES
It should respond with 'Hello, World!' => ./test_server.ts:25:6
FAILED | 0 passed | 1 failed (14ms)
error: Test failed
7 replies