-
Notifications
You must be signed in to change notification settings - Fork 92
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
12 changed files
with
168 additions
and
49 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
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
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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import fs from 'fs' | ||
|
||
const RUNTIME_PUBLIC_PATH = '/@vite-plugin-checker-runtime' | ||
const RUNTIME_FILE_PATH = require.resolve('../@runtime/main.js') | ||
const WS_CHECKER_ERROR_EVENT = 'vite-plugin-checker:error' | ||
const WS_CHECKER_RECONNECT_EVENT = 'vite-plugin-checker:reconnect' | ||
// #region | ||
// NOTE: sync modification with packages/runtime/src/ws.js | ||
export const RUNTIME_PUBLIC_PATH = '/@vite-plugin-checker-runtime' | ||
export const RUNTIME_FILE_PATH = require.resolve('../@runtime/main.js') | ||
export const WS_CHECKER_ERROR_EVENT = 'vite-plugin-checker:error' | ||
export const WS_CHECKER_RECONNECT_EVENT = 'vite-plugin-checker:reconnect' | ||
export const WS_CHECKER_CONFIG_RUNTIME_EVENT = 'vite-plugin-checker:config-runtime' | ||
// #endregion | ||
|
||
const runtimeCode = `${fs.readFileSync(RUNTIME_FILE_PATH, 'utf-8')};` | ||
|
||
export { runtimeCode, RUNTIME_PUBLIC_PATH, WS_CHECKER_ERROR_EVENT, WS_CHECKER_RECONNECT_EVENT } | ||
export const runtimeCode = `${fs.readFileSync(RUNTIME_FILE_PATH, 'utf-8')};` |
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
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,50 @@ | ||
import { | ||
getHmrOverlayText, | ||
killServer, | ||
preTest, | ||
viteServe, | ||
} from 'vite-plugin-checker/__tests__/e2e/Sandbox/Sandbox' | ||
import { | ||
editFile, | ||
sleep, | ||
testDir, | ||
WORKER_CLEAN_TIMEOUT, | ||
} from 'vite-plugin-checker/__tests__/e2e/testUtils' | ||
|
||
import { copyCode } from '../../../scripts/jestSetupFilesAfterEnv' | ||
import { serializers } from '../../../scripts/serializers' | ||
|
||
expect.addSnapshotSerializer(serializers) | ||
|
||
beforeAll(async () => { | ||
await preTest() | ||
}) | ||
|
||
afterAll(async () => { | ||
await sleep(WORKER_CLEAN_TIMEOUT) | ||
}) | ||
|
||
describe('overlay-config', () => { | ||
beforeEach(async () => { | ||
await copyCode() | ||
}) | ||
|
||
afterEach(async () => { | ||
await killServer() | ||
}) | ||
|
||
it('overlay: config', async () => { | ||
editFile('vite.config.ts', (code) => | ||
code.replace( | ||
'typescript: true,', | ||
`typescript: true, overlay: { position: 'br', initialIsOpen: false, },` | ||
) | ||
) | ||
|
||
await viteServe({ cwd: testDir, launchPage: true }) | ||
await sleep(6000) | ||
await expect(getHmrOverlayText()).rejects.toThrow( | ||
'Invariant failed: <vite-plugin-checker-error-overlay> shadow dom is expected to be found, but got null' | ||
) | ||
}) | ||
}) |
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
Oops, something went wrong.