-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add watch in fallback file load
- Loading branch information
1 parent
374e6fd
commit b70073f
Showing
6 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
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
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,10 @@ | ||
import { expect, test } from 'vitest' | ||
|
||
import { editFile, isServe, page, untilUpdated } from '~utils' | ||
|
||
test.runIf(isServe)('should watch files outside root', async () => { | ||
expect(await page.textContent('#foo')).toBe('foo') | ||
editFile('foo.js', (code) => code.replace("'foo'", "'foobar'")) | ||
await page.waitForEvent('load') | ||
await untilUpdated(async () => await page.textContent('#foo'), 'foobar') | ||
}) |
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 @@ | ||
export const foo = 'foo' |
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,7 @@ | ||
<div id="foo"></div> | ||
|
||
<script type="module"> | ||
import { foo } from '../foo.js' | ||
|
||
document.querySelector('#foo').textContent = foo | ||
</script> |
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,9 @@ | ||
import path from 'node:path' | ||
import url from 'node:url' | ||
import { defineConfig } from 'vite' | ||
|
||
const __dirname = path.dirname(url.fileURLToPath(import.meta.url)) | ||
|
||
export default defineConfig({ | ||
root: path.join(__dirname, './root'), | ||
}) |
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,14 @@ | ||
import { expect, test } from 'vitest' | ||
|
||
import { editFile, isServe, page, untilUpdated } from '~utils' | ||
|
||
test.runIf(isServe)('should render', async () => { | ||
expect(await page.textContent('#foo')).toBe('foo') | ||
}) | ||
|
||
test.runIf(isServe)('should watch files outside root', async () => { | ||
expect(await page.textContent('#foo')).toBe('bar') | ||
editFile('foo.js', (code) => code.replace("'foo'", "'foobar'")) | ||
await page.waitForEvent('load') | ||
await untilUpdated(async () => await page.textContent('#foo'), 'foobar') | ||
}) |