diff --git a/playground/assets/__tests__/assets.spec.ts b/playground/assets/__tests__/assets.spec.ts index 70d0fcfe4e8e54..ab482bcdef3d2b 100644 --- a/playground/assets/__tests__/assets.spec.ts +++ b/playground/assets/__tests__/assets.spec.ts @@ -8,6 +8,7 @@ import { getBg, getColor, isBuild, + isServe, listAssets, notifyRebuildComplete, page, @@ -60,6 +61,22 @@ test('should fallback to index.html when accessing non-existant html file', asyn expect((await fetchPath('doesnt-exist.html')).status).toBe(200) }) +describe.runIf(isServe)('outside base', () => { + test('should get a 404 with html', async () => { + const res = await fetch(new URL('/baz', viteTestUrl), { + headers: { Accept: 'text/html,*/*' }, + }) + expect(res.status).toBe(404) + expect(res.headers.get('Content-Type')).toBe('text/html') + }) + + test('should get a 404 with text', async () => { + const res = await fetch(new URL('/baz', viteTestUrl)) + expect(res.status).toBe(404) + expect(res.headers.get('Content-Type')).toBe('text/plain') + }) +}) + describe('injected scripts', () => { test('@vite/client', async () => { const hasClient = await page.$(