Skip to content

Commit 00f0412

Browse files
committed
test(fixture): update test case
1 parent 1d7e939 commit 00f0412

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

test/e2e/middleware-custom-matchers/app/middleware.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,13 @@ export const config = {
7777
},
7878
],
7979
},
80+
{
81+
source:
82+
'/((?!api|monitoring|_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt|manifest|icon|source-match|has-match-1|has-match-2|has-match-3|has-match-4|has-match-5|missing-match-1|missing-match-2|routes).*)',
83+
missing: [
84+
{ type: 'header', key: 'next-router-prefetch' },
85+
{ type: 'header', key: 'purpose', value: 'prefetch' },
86+
],
87+
},
8088
],
8189
}

test/e2e/middleware-custom-matchers/test/index.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ describe('Middleware custom matchers', () => {
3131
},
3232
})
3333
expect(res2.headers.get('x-from-middleware')).toBeFalsy()
34+
35+
const res3 = await fetchViaHTTP(next.url, '/')
36+
expect(res3.headers.get('x-from-middleware')).toBeDefined()
37+
38+
const res4 = await fetchViaHTTP(next.url, '/', undefined, {
39+
headers: {
40+
purpose: 'prefetch',
41+
},
42+
})
43+
expect(res4.headers.get('x-from-middleware')).toBeFalsy()
3444
})
3545

3646
it('should match missing query correctly', async () => {

0 commit comments

Comments
 (0)