@@ -57,6 +57,61 @@ test("Vite / HMR & HDR / express", async ({ page, browserName, customDev }) => {
5757 await workflow ( { page, browserName, cwd, port } ) ;
5858} ) ;
5959
60+ test ( "Vite / HMR & HDR / mdx" , async ( { page, viteDev } ) => {
61+ let files : Files = async ( { port } ) => ( {
62+ "vite.config.ts" : `
63+ import { defineConfig } from "vite";
64+ import { unstable_vitePlugin as remix } from "@remix-run/dev";
65+ import mdx from "@mdx-js/rollup";
66+
67+ export default defineConfig({
68+ ${ await viteConfig . server ( { port } ) }
69+ plugins: [
70+ mdx(),
71+ remix(),
72+ ],
73+ });
74+ ` ,
75+ "app/component.tsx" : `
76+ import {useState} from "react";
77+
78+ export const Counter = () => {
79+ const [count, setCount] = useState(0);
80+ return <button onClick={() => setCount(count => count + 1)}>Count: {count}</button>
81+ }
82+ ` ,
83+ "app/routes/mdx.mdx" : `
84+ import { Counter } from "../component";
85+
86+ # MDX Title (HMR: 0)
87+
88+ <Counter />
89+ ` ,
90+ } ) ;
91+
92+ let { port, cwd } = await viteDev ( files ) ;
93+ let edit = createEditor ( cwd ) ;
94+ await page . goto ( `http://localhost:${ port } /mdx` , {
95+ waitUntil : "networkidle" ,
96+ } ) ;
97+
98+ await expect ( page . locator ( "h1" ) ) . toHaveText ( "MDX Title (HMR: 0)" ) ;
99+ let button = page . locator ( "button" ) ;
100+ await expect ( button ) . toHaveText ( "Count: 0" ) ;
101+ await button . click ( ) ;
102+ await expect ( button ) . toHaveText ( "Count: 1" ) ;
103+
104+ await edit ( "app/routes/mdx.mdx" , ( contents ) =>
105+ contents . replace ( "(HMR: 0)" , "(HMR: 1)" )
106+ ) ;
107+ await page . waitForLoadState ( "networkidle" ) ;
108+
109+ await expect ( page . locator ( "h1" ) ) . toHaveText ( "MDX Title (HMR: 1)" ) ;
110+ await expect ( page . locator ( "button" ) ) . toHaveText ( "Count: 1" ) ;
111+
112+ expect ( page . errors ) . toEqual ( [ ] ) ;
113+ } ) ;
114+
60115async function workflow ( {
61116 page,
62117 browserName,
0 commit comments