Skip to content

Commit

Permalink
test: add test for vitejs/vite#14127
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphi-red committed Aug 15, 2024
1 parent 31ade6a commit cade843
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion tests/examples-cases/middleware-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,33 @@ test('restart test', async ({ page }) => {
}
})

// https://github.com/vitejs/vite/pull/14127
test('restart server by config change', async ({page}) => {
const finishVite = await startVite()
try {
await setupAndGotoPage(page)

// edit vite.config.js to restart server
await editFile('./vite.config.js', workspaceFileURL, content =>
content.replace('export default defineConfig({', 'export default defineConfig({\n')
)

const title = page.locator('h1')
await expect(title).toHaveText('Hello Vite!!!')

await editFile('./src/main.js', workspaceFileURL, content =>
content.replace('Vite!!!</h1>', 'Vite!!!!</h1>')
)

await expect(title).toHaveText('Hello Vite!!!!')
} finally {
await finishVite()
}
})

test.afterAll(async () => {
// cleanup
await editFile('./src/main.js', workspaceFileURL, content =>
content.replace('Vite!!!</h1>', 'Vite!</h1>')
content.replace('Vite!!!!</h1>', 'Vite!</h1>')
)
})

0 comments on commit cade843

Please sign in to comment.