MCPcopy
hub / github.com/vercel/next.js / didPrefetch

Function didPrefetch

test/integration/link-ref-pages/test/index.test.ts:37–55  ·  view source on GitHub ↗
(pathname)

Source from the content-addressed store, hash-verified

35}
36
37const didPrefetch = async (pathname) => {
38 const browser = await webdriver(appPort, pathname)
39
40 let chunk = getClientBuildManifestLoaderChunkUrlPath(appDir, '/')
41
42 await retry(async () => {
43 const links = await browser.elementsByCss('link[rel=prefetch]')
44
45 const hrefs = await Promise.all(
46 links.map((link) => link.getAttribute('href'))
47 )
48
49 expect(hrefs).toEqual(
50 expect.arrayContaining([expect.stringContaining(chunk)])
51 )
52 })
53
54 await browser.close()
55}
56
57function runCommonTests() {
58 // See https://github.com/vercel/next.js/issues/18437

Callers 1

index.test.tsFile · 0.70

Calls 9

retryFunction · 0.90
webdriverFunction · 0.85
elementsByCssMethod · 0.80
allMethod · 0.80
getAttributeMethod · 0.80
closeMethod · 0.65
expectFunction · 0.50
mapMethod · 0.45

Tested by

no test coverage detected