Skip to content

Commit

Permalink
1. Fix: Update file import and headers formatting
Browse files Browse the repository at this point in the history
2. Refactor: Add missing comma and change quotes for consistency

3. Refactor: Add missing comma for better syntax consistency

4. Fix: Add missing comma for syntax correctness

5. Refactor: Change quotes for consistency and clarity

6. Fix: Add missing comma in spawn options

7. Fix: Add missing comma in spawn options

8. Fix: Add missing comma in process arrow function

9. Fix: Correct page URL to use consistent quotes

10. Fix: Change quoting for page innerText comparison

11. Refactor: Change quoting for page innerText comparison

12. Refactor: Change quoting for text replacement

13. Refactor: Change quoting in text replacement

14. Refactor: Change quoting for waitForEvent parameter

15. Refactor: Change quoting for waitForEvent parameter
  • Loading branch information
aabccd021 committed Dec 5, 2024
1 parent c425e79 commit c192195
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
6 changes: 3 additions & 3 deletions example.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { withHtmlLiveReload } from './index.ts';
import { withHtmlLiveReload } from "./index.ts";

Bun.serve({
fetch: withHtmlLiveReload(async () => {
return new Response("<div>Init</div>", {
headers: { "Content-Type": "text/html", },
headers: { "Content-Type": "text/html" },
});
})
}),
});
21 changes: 11 additions & 10 deletions test/reloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,34 @@ const tmpdir = fs.mkdtempSync(`${systemTmp}/bun-`);
fs.copyFileSync(`${import.meta.dir}/../example.ts`, `${tmpdir}/example.ts`);
fs.copyFileSync(`${import.meta.dir}/../index.ts`, `${tmpdir}/index.ts`);


const child = Bun.spawn(["bun", "--hot", `${tmpdir}/example.ts`], { stderr: "ignore" })
const child = Bun.spawn(["bun", "--hot", `${tmpdir}/example.ts`], {
stderr: "ignore",
});

process.on("exit", async () => {
child?.kill();
await browser.close();
})
});

const browser = await chromium.launch();

const context = await browser.newContext();
const page = await context.newPage();
await page.goto('http://localhost:3000');
await page.goto("http://localhost:3000");

const name = await page.innerText('div');
if (name !== 'Init') {
const name = await page.innerText("div");
if (name !== "Init") {
throw new Error(`Unexpected content ${name}`);
}

const text = await Bun.file(`${tmpdir}/example.ts`).text();
const newText = text.replace('Init', 'Changed');
const newText = text.replace("Init", "Changed");
await Bun.write(`${tmpdir}/example.ts`, newText);

await page.waitForEvent('framenavigated');
await page.waitForEvent("framenavigated");

const newName = await page.innerText('div');
if (newName !== 'Changed') {
const newName = await page.innerText("div");
if (newName !== "Changed") {
throw new Error(`Unexpected content: ${newName}`);
}

Expand Down

0 comments on commit c192195

Please sign in to comment.