|
| 1 | +import { expect, test } from "@playwright/test"; |
| 2 | +import { |
| 3 | + setupDevServer, |
| 4 | + setupBuildAndPreview, |
| 5 | + setupWaitForLogs, |
| 6 | +} from "../../utils.js"; |
| 7 | + |
| 8 | +test("MDX build", async ({ page }) => { |
| 9 | + const { testUrl, server } = await setupBuildAndPreview("mdx"); |
| 10 | + await page.goto(testUrl); |
| 11 | + await expect(page.getByRole("heading", { name: "Hello" })).toBeVisible(); |
| 12 | + await server.httpServer.close(); |
| 13 | +}); |
| 14 | + |
| 15 | +test("MDX HMR", async ({ page }) => { |
| 16 | + const { testUrl, server, editFile } = await setupDevServer("mdx"); |
| 17 | + const waitForLogs = await setupWaitForLogs(page); |
| 18 | + await page.goto(testUrl); |
| 19 | + await waitForLogs("[vite] connected."); |
| 20 | + |
| 21 | + editFile("src/Counter.tsx", ["{count}", "{count}!"]); |
| 22 | + await waitForLogs("[vite] hot updated: /src/Counter.tsx"); |
| 23 | + const button = await page.locator("button"); |
| 24 | + await button.click(); |
| 25 | + await expect(button).toHaveText("count is 1!"); |
| 26 | + |
| 27 | + editFile("src/hello.mdx", ["Hello", "Hello world"]); |
| 28 | + await waitForLogs("[vite] hot updated: /src/hello.mdx"); |
| 29 | + await expect( |
| 30 | + page.getByRole("heading", { name: "Hello world" }), |
| 31 | + ).toBeVisible(); |
| 32 | + await expect(button).toHaveText("count is 1!"); |
| 33 | + |
| 34 | + await server.close(); |
| 35 | +}); |
0 commit comments