-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
68 additions
and
211 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
44 changes: 0 additions & 44 deletions
44
playground/config-initialIsOpen-error-clean/__tests__/test.spec.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
playground/config-initialIsOpen-error-clean/vite.config.js
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
playground/config-initialIsOpen-error-warnings/__tests__/__snapshots__/test.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
||
exports[`config-initialIsOpen-error-warnings > serve > should not show overlay when only warning exists 1`] = ` | ||
" 1 | import { text } from './text' | ||
2 | | ||
> 3 | var rootDom = document.querySelector('#root')! as HTMLElement | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
4 | rootDom.innerHTML = text | ||
5 | | ||
6 | export {}" | ||
`; |
47 changes: 25 additions & 22 deletions
47
playground/config-initialIsOpen-error-warnings/__tests__/test.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,34 @@ | ||
import { describe, expect, it } from 'vitest' | ||
|
||
import { editFile, getHmrOverlayText, isServe, sleepForEdit, sleepForServerReady } from '../../testUtils' | ||
import { | ||
editFile, | ||
getHmrOverlay, | ||
getHmrOverlayText, | ||
isServe, | ||
pollingUntil, | ||
sleepForEdit, | ||
sleepForServerReady, | ||
} from '../../testUtils' | ||
|
||
describe('config-initialIsOpen-error-warnings', () => { | ||
describe.runIf(isServe)('serve', () => { | ||
it('should not find overlay', async () => { | ||
if (isServe) { | ||
await sleepForServerReady() | ||
try { | ||
await getHmrOverlayText() | ||
} catch (e) { | ||
expect((e as any).toString()).toContain( | ||
'Invariant failed: <vite-plugin-checker-error-overlay> shadow dom is expected to be found, but got null' | ||
) | ||
} | ||
|
||
console.log('-- overlay remains closed after introduced error --') | ||
editFile('src/main.ts', (code) => code.replace('! as', '! is')) | ||
await sleepForEdit() | ||
try { | ||
await getHmrOverlayText() | ||
} catch (e) { | ||
expect((e as any).toString()).toContain( | ||
'Invariant failed: <vite-plugin-checker-error-overlay> shadow dom is expected to be found, but got null' | ||
) | ||
} | ||
it('should not show overlay when only warning exists', async () => { | ||
await sleepForServerReady() | ||
try { | ||
await getHmrOverlayText() | ||
} catch (e) { | ||
expect((e as any).toString()).toContain( | ||
'Invariant failed: <vite-plugin-checker-error-overlay> shadow dom is expected to be found, but got null' | ||
) | ||
} | ||
|
||
console.log('-- overlay appears after introduce an error --') | ||
editFile('src/main.ts', (code) => code.replace('const rootDom', 'var rootDom')) | ||
await sleepForEdit() | ||
await getHmrOverlayText() | ||
await pollingUntil(getHmrOverlay, (dom) => !!dom) | ||
const [, , frame] = await getHmrOverlayText() | ||
expect(frame).toMatchSnapshot() | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 28 additions & 21 deletions
49
playground/config-initialIsOpen-error/__tests__/test.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,38 @@ | ||
import { describe, expect, it } from 'vitest' | ||
|
||
import { editFile, getHmrOverlay, getHmrOverlayText, isServe, pollingUntil, sleep, sleepForEdit, sleepForServerReady } from '../../testUtils' | ||
import { | ||
editFile, | ||
getHmrOverlay, | ||
getHmrOverlayText, | ||
isServe, | ||
pollingUntil, | ||
sleep, | ||
sleepForEdit, | ||
sleepForServerReady, | ||
} from '../../testUtils' | ||
|
||
describe('config-initialIsOpen-error', () => { | ||
describe.runIf(isServe)('serve', () => { | ||
it('should find overlay', async () => { | ||
if (isServe) { | ||
await sleepForServerReady() | ||
const [message1, file1, frame1] = await getHmrOverlayText() | ||
expect(message1).toMatchSnapshot() | ||
expect(file1).toMatchSnapshot() | ||
expect(frame1).toMatchSnapshot() | ||
it('-- should find overlay with error --', async () => { | ||
await sleepForServerReady() | ||
const [message1, file1, frame1] = await getHmrOverlayText() | ||
expect(message1).toMatchSnapshot() | ||
expect(file1).toMatchSnapshot() | ||
expect(frame1).toMatchSnapshot() | ||
|
||
console.log('-- overlay remains after fix error --') | ||
editFile('src/main.ts', (code) => code.replace('var hello', `const hello`)) | ||
await sleepForEdit() | ||
await pollingUntil(getHmrOverlay, (dom) => !!dom) | ||
const [, , frame2] = await getHmrOverlayText() | ||
expect(frame2).toMatchSnapshot() | ||
console.log('-- overlay remains after fix error --') | ||
editFile('src/main.ts', (code) => code.replace('var hello', `const hello`)) | ||
await sleepForEdit() | ||
await pollingUntil(getHmrOverlay, (dom) => !!dom) | ||
const [, , frame2] = await getHmrOverlayText() | ||
expect(frame2).toMatchSnapshot() | ||
|
||
console.log('-- overlay dismiss after fix warning --') | ||
editFile('src/main.ts', (code) => code.replace('! as', ` as`)) | ||
await sleep(6000) | ||
await expect(getHmrOverlayText()).rejects.toThrow( | ||
'Invariant failed: .message-body is expected in shadow root' | ||
) | ||
} | ||
console.log('-- overlay dismiss after fix warning --') | ||
editFile('src/main.ts', (code) => code.replace('! as', ` as`)) | ||
await sleep(6000) | ||
await expect(getHmrOverlayText()).rejects.toThrow( | ||
'Invariant failed: .message-body is expected in shadow root' | ||
) | ||
}) | ||
}) | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.