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

Function testStarExports

playground/hmr/__tests__/hmr.spec.ts:716–786  ·  view source on GitHub ↗
(testDirName: string)

Source from the content-addressed store, hash-verified

714
715 describe('indiscriminate imports: import *', () => {
716 const testStarExports = (testDirName: string) => {
717 const testDir = `${baseDir}/${testDirName}`
718
719 it('accepts itself if all its exports are accepted', async () => {
720 const fileName = 'deps-all-accepted.ts'
721 const file = `${testDir}/${fileName}`
722 const url = '/' + file
723
724 await untilBrowserLogAfter(
725 () => page.goto(`${viteTestUrl}/${testDir}/`),
726 [CONNECTED, '>>> ready <<<'],
727 (logs) => {
728 expect(logs).toContain('loaded:all:a0b0c0default0')
729 expect(logs).toContain('all >>>>>> a0, b0, c0')
730 },
731 )
732
733 await untilBrowserLogAfter(
734 () => {
735 editFile(file, (code) => code.replace(/([abc])0/g, '$11') + '\n')
736 },
737 HOT_UPDATED,
738 (logs) => {
739 expect(logs).toEqual([
740 'all >>>>>> a1, b1, c1',
741 `[vite] hot updated: ${url}`,
742 ])
743 },
744 )
745
746 await untilBrowserLogAfter(
747 () => {
748 editFile(file, (code) => code.replace(/([abc])1/g, '$12') + '\n')
749 },
750 HOT_UPDATED,
751 (logs) => {
752 expect(logs).toEqual([
753 'all >>>>>> a2, b2, c2',
754 `[vite] hot updated: ${url}`,
755 ])
756 },
757 )
758 })
759
760 it("doesn't accept itself if one export is not accepted", async () => {
761 const fileName = 'deps-some-accepted.ts'
762 const file = `${testDir}/${fileName}`
763
764 await untilBrowserLogAfter(
765 () => page.goto(`${viteTestUrl}/${testDir}/`),
766 [CONNECTED, '>>> ready <<<'],
767 (logs) => {
768 expect(logs).toContain('loaded:some:a0b0c0default0')
769 expect(logs).toContain('some >>>>>> a0, b0, c0')
770 },
771 )
772
773 await untilBrowserLogAfter(

Callers 1

hmr.spec.tsFile · 0.70

Calls 2

untilBrowserLogAfterFunction · 0.85
editFileFunction · 0.50

Tested by

no test coverage detected