|
1 |
| -import { getColor, isBuild } from '../../testUtils' |
| 1 | +import { getColor, isBuild, editFile } from '../../testUtils' |
2 | 2 |
|
3 | 3 | function testPage(isNested: boolean) {
|
4 | 4 | test('pre transform', async () => {
|
@@ -210,3 +210,29 @@ describe('unicode path', () => {
|
210 | 210 | expect(await page.textContent('h1')).toBe('unicode-path')
|
211 | 211 | })
|
212 | 212 | })
|
| 213 | + |
| 214 | +if (!isBuild) { |
| 215 | + describe('invalid', () => { |
| 216 | + test('should be 500 with overlay', async () => { |
| 217 | + const response = await page.goto(viteTestUrl + '/invalid.html') |
| 218 | + expect(response.status()).toBe(500) |
| 219 | + |
| 220 | + const errorOverlay = await page.waitForSelector('vite-error-overlay') |
| 221 | + expect(errorOverlay).toBeTruthy() |
| 222 | + |
| 223 | + const message = await errorOverlay.$$eval('.message-body', (m) => { |
| 224 | + return m[0].innerHTML |
| 225 | + }) |
| 226 | + expect(message).toMatch(/^Unable to parse HTML/) |
| 227 | + }) |
| 228 | + |
| 229 | + test('should reload when fixed', async () => { |
| 230 | + const response = await page.goto(viteTestUrl + '/invalid.html') |
| 231 | + await editFile('invalid.html', (content) => { |
| 232 | + return content.replace('<div Bad', '<div> Good') |
| 233 | + }) |
| 234 | + const content = await page.waitForSelector('text=Good Html') |
| 235 | + expect(content).toBeTruthy() |
| 236 | + }) |
| 237 | + }) |
| 238 | +} |
0 commit comments