MCPcopy
hub / github.com/nuxt/nuxt / expectNavigatesWithLoading

Function expectNavigatesWithLoading

test/nuxt/loading-indicator.test.ts:95–117  ·  view source on GitHub ↗
(path: string | RouteLocationRaw, onLoad?: () => void)

Source from the content-addressed store, hash-verified

93 const getPage = () => el.getComponent('#page')
94
95 async function expectNavigatesWithLoading (path: string | RouteLocationRaw, onLoad?: () => void) {
96 startedLoading = 0
97 stoppedLoading = 0
98 await navigateTo(path)
99 expect(startedLoading).toBe(1)
100 expect(stoppedLoading).toBe(0)
101
102 expect(isLoading.value).toBe(true)
103 expect(getLoadingIndicator().attributes().style).toContain('opacity: 1;')
104 onLoad?.()
105
106 if (isLoading.value) {
107 resolve!()
108 await new Promise<void>(resolve => nuxtApp.hooks.hookOnce('page:loading:end', () => { resolve() }))
109 .then(() => new Promise(r => setTimeout(r, 0)))
110 }
111
112 expect(startedLoading).toBe(1)
113 expect(stoppedLoading).toBe(1)
114
115 expect(isLoading.value).toBe(false)
116 expect(getLoadingIndicator().attributes().style).toContain('opacity: 0;')
117 }
118
119 await flushPromises()
120

Callers 1

Calls 2

navigateToFunction · 0.85
getLoadingIndicatorFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…