-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Simplify test command in deploy and test workflows, delete …
…unused files.
- Loading branch information
Showing
5 changed files
with
65 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,4 @@ jobs: | |
|
||
- run: bun run typescript-check | ||
|
||
- run: bun test/reloads.ts | ||
- run: bun test |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { chromium } from "playwright"; | ||
import * as fs from "fs"; | ||
import { afterEach, expect, test } from "bun:test"; | ||
|
||
const serverCodeInit = ` | ||
import { withHtmlLiveReload } from "./bun-html-live-reload.ts"; | ||
Bun.serve({ | ||
fetch: withHtmlLiveReload(async () => { | ||
return new Response("<div>Init</div>", { | ||
headers: { "Content-Type": "text/html" }, | ||
}); | ||
}), | ||
}); | ||
`; | ||
|
||
const serverCodeChanged = ` | ||
import { withHtmlLiveReload } from "./bun-html-live-reload.ts"; | ||
Bun.serve({ | ||
fetch: withHtmlLiveReload(async () => { | ||
return new Response("<div>Changed</div>", { | ||
headers: { "Content-Type": "text/html" }, | ||
}); | ||
}), | ||
}); | ||
`; | ||
|
||
let close: () => Promise<void> | undefined; | ||
|
||
afterEach(async () => { | ||
await close?.(); | ||
}) | ||
|
||
test("hot reload works", async () => { | ||
const systemTmp = process.env["TMPDIR"] ?? "/tmp"; | ||
const tmpdir = fs.mkdtempSync(`${systemTmp}/bun-`); | ||
const serverPath = `${tmpdir}/server.ts`; | ||
const libPath = `${tmpdir}/bun-html-live-reload.ts`; | ||
|
||
await Bun.write(serverPath, serverCodeInit); | ||
|
||
fs.copyFileSync(`${import.meta.dir}/index.ts`, libPath); | ||
|
||
const child = Bun.spawn(["bun", "--hot", serverPath], { stderr: "ignore" }); | ||
|
||
const browser = await chromium.launch(); | ||
|
||
close = async () => { | ||
child?.kill(); | ||
await browser.close(); | ||
}; | ||
|
||
const context = await browser.newContext(); | ||
const page = await context.newPage(); | ||
await page.goto("http://localhost:3000"); | ||
|
||
expect(await page.innerText("div")).toBe("Init"); | ||
|
||
await Bun.write(serverPath, serverCodeChanged); | ||
await page.waitForEvent("framenavigated"); | ||
|
||
expect(await page.innerText("div")).toBe("Changed"); | ||
}); |
This file was deleted.
Oops, something went wrong.