From 9b7ed6217ecbd7efd8720dc1921e94974e7adcb6 Mon Sep 17 00:00:00 2001 From: Max Duval Date: Wed, 26 Apr 2023 15:11:59 +0100 Subject: [PATCH] tests: end-to-end build & dev --- deno.lock | 3 +++ src/build.test.ts | 52 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 src/build.test.ts diff --git a/deno.lock b/deno.lock index 8f522ab..52f172f 100644 --- a/deno.lock +++ b/deno.lock @@ -226,6 +226,9 @@ "https://deno.land/std@0.177.0/path/separator.ts": "0fb679739d0d1d7bf45b68dacfb4ec7563597a902edbaf3c59b50d5bcadd93b1", "https://deno.land/std@0.177.0/path/win32.ts": "d186344e5583bcbf8b18af416d13d82b35a317116e6460a5a3953508c3de5bba", "https://deno.land/std@0.177.0/streams/write_all.ts": "3b2e1ce44913f966348ce353d02fa5369e94115181037cd8b602510853ec3033", + "https://deno.land/std@0.177.0/testing/_diff.ts": "1a3c044aedf77647d6cac86b798c6417603361b66b54c53331b312caeb447aea", + "https://deno.land/std@0.177.0/testing/_format.ts": "a69126e8a469009adf4cf2a50af889aca364c349797e63174884a52ff75cf4c7", + "https://deno.land/std@0.177.0/testing/asserts.ts": "984ab0bfb3faeed92ffaa3a6b06536c66811185328c5dd146257c702c41b01ab", "https://deno.land/std@0.177.0/types.d.ts": "220ed56662a0bd393ba5d124aa6ae2ad36a00d2fcbc0e8666a65f4606aaa9784", "https://deno.land/std@0.177.0/version.ts": "259c8866ec257c3511b437baa95205a86761abaef852a9b2199072accb2ef046", "https://deno.land/std@0.179.0/_util/asserts.ts": "178dfc49a464aee693a7e285567b3d0b555dc805ff490505a8aae34f9cfb1462", diff --git a/src/build.test.ts b/src/build.test.ts new file mode 100644 index 0000000..8e634c4 --- /dev/null +++ b/src/build.test.ts @@ -0,0 +1,52 @@ +import { + assert, + assertEquals, +} from "https://deno.land/std@0.177.0/testing/asserts.ts"; + +Deno.test({ + name: "Able to build the current project", + permissions: { run: true }, + fn: async () => { + const process = Deno.run({ + cmd: ["deno", "task", "build"], + stdout: "null", + stderr: "null", + }); + + const { success } = await process.status(); + assert(success); + process.close(); + }, +}); + +Deno.test({ + name: "Able to develop the current project", + permissions: { run: true, net: true }, + fn: async () => { + const process = Deno.run({ + cmd: ["deno", "task", "dev"], + stdout: "null", + stderr: "null", + }); + + await new Promise((resolve) => { + setTimeout(() => { + resolve(); + }, 600); + }); + + const response = await fetch("http://localhost:4507/mononykus/"); + assertEquals(response.status, 200); + const html = await response.text(); + + process.kill(); + process.close(); + + assert(html.startsWith( + "", + )); + assert(html.includes( + "Mononykus – Deno + Svelte", + )); + }, +});