Skip to content

Commit 2b133ff

Browse files
committed
test: assert that _next/static have immutable cache control
1 parent f4b59b6 commit 2b133ff

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: tests/utils/playwright-helpers.ts

+16
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const makeE2EFixture = (
1414

1515
export const test = base.extend<
1616
{
17+
ensureStaticAssetsHaveImmutableCacheControl: void
1718
takeScreenshot: void
1819
pollUntilHeadersMatch: (
1920
url: string,
@@ -91,4 +92,19 @@ export const test = base.extend<
9192
},
9293
{ auto: true },
9394
],
95+
ensureStaticAssetsHaveImmutableCacheControl: [
96+
async ({ page }, use) => {
97+
page.on('response', (response) => {
98+
if (response.url().includes('/_next/static/')) {
99+
expect(
100+
response.headers()['cache-control'],
101+
'_next/static assets should have immutable cache control',
102+
).toContain('public,max-age=31536000,immutable')
103+
}
104+
})
105+
106+
await use()
107+
},
108+
{ auto: true },
109+
],
94110
})

0 commit comments

Comments
 (0)