chore: speed up tests (#1791)

This PR speeds up tests by handling custom created `Requests` object
directly instead of binding a socket and making a real HTTP request. For
most tests this is fine, and for those that aren't the existing testing
methods are all preserved.
This commit is contained in:
Marvin Hagemeister
2023-09-18 18:44:22 +02:00
committed by GitHub
parent c76f15479f
commit 3850131063
12 changed files with 247 additions and 158 deletions
+6 -7
View File
@@ -10,9 +10,8 @@ import {
assertSelector,
assertTextMatch,
clickWhenListenerReady,
fetchHtml,
waitForText,
withFresh,
withFakeServe,
withPageName,
} from "./test_utils.ts";
@@ -503,21 +502,21 @@ Deno.test({
});
Deno.test("throws when passing non-jsx children to an island", async (t) => {
await withFresh(
await withFakeServe(
"./tests/fixture_island_nesting/dev.ts",
async (address) => {
const doc = await fetchHtml(`${address}/island_invalid_children`);
async (server) => {
const doc = await server.getHtml(`/island_invalid_children`);
assertSelector(doc, ".frsh-error-page");
assertTextMatch(doc, "pre", /Invalid JSX child passed to island/);
const doc2 = await fetchHtml(`${address}/island_invalid_children_fn`);
const doc2 = await server.getHtml(`/island_invalid_children_fn`);
assertSelector(doc2, ".frsh-error-page");
assertTextMatch(doc2, "pre", /Invalid JSX child passed to island/);
await t.step("should not throw on valid children", async () => {
const doc2 = await fetchHtml(`${address}/island_valid_children`);
const doc2 = await server.getHtml(`/island_valid_children`);
assertNotSelector(doc2, ".frsh-error-page");
});