MCPcopy
hub / github.com/vitejs/vite / testStarExports

Function testStarExports

playground/hmr-ssr/__tests__/hmr-ssr.spec.ts:679–741  ·  view source on GitHub ↗
(testDirName: string)

Source from the content-addressed store, hash-verified

677
678 describe('indiscriminate imports: import *', () => {
679 const testStarExports = (testDirName: string) => {
680 const testDir = `${baseDir}/${testDirName}`
681
682 test('accepts itself if all its exports are accepted', async () => {
683 const fileName = 'deps-all-accepted.ts'
684 const file = `${testDir}/${fileName}`
685 const url = '/' + file
686
687 await untilConsoleLogAfter(
688 () => setupModuleRunner(`/${testDir}/index`),
689 [CONNECTED, '>>> ready <<<'],
690 (logs) => {
691 expect(logs).toContain('loaded:all:a0b0c0default0')
692 expect(logs).toContain('all >>>>>> a0, b0, c0')
693 },
694 )
695
696 await untilConsoleLogAfter(
697 () => {
698 editFile(file, (code) => code.replace(/([abc])0/g, '$11') + '\n')
699 },
700 HOT_UPDATED,
701 (logs) => {
702 expect(logs).toEqual(['all >>>>>> a1, b1, c1', updated(url)])
703 },
704 )
705
706 await untilConsoleLogAfter(
707 () => {
708 editFile(file, (code) => code.replace(/([abc])1/g, '$12') + '\n')
709 },
710 HOT_UPDATED,
711 (logs) => {
712 expect(logs).toEqual(['all >>>>>> a2, b2, c2', updated(url)])
713 },
714 )
715 })
716
717 test("doesn't accept itself if one export is not accepted", async () => {
718 const fileName = 'deps-some-accepted.ts'
719 const file = `${testDir}/${fileName}`
720
721 await untilConsoleLogAfter(
722 () => setupModuleRunner(`/${testDir}/index`),
723 [CONNECTED, '>>> ready <<<'],
724 (logs) => {
725 expect(logs).toContain('loaded:some:a0b0c0default0')
726 expect(logs).toContain('some >>>>>> a0, b0, c0')
727 },
728 )
729
730 await untilConsoleLogAfter(
731 async () => {
732 editFile(file, (code) => code.replace(/([abc])0/g, '$11') + '\n')
733 },
734 [PROGRAM_RELOAD, '>>> ready <<<'],
735 (logs) => {
736 expect(logs).toContain('loaded:some:a1b1c1default0')

Callers 1

hmr-ssr.spec.tsFile · 0.70

Calls 5

testFunction · 0.90
untilConsoleLogAfterFunction · 0.85
setupModuleRunnerFunction · 0.85
updatedFunction · 0.85
editFileFunction · 0.50

Tested by

no test coverage detected