Skip to content

Commit e657c38

Browse files
authored
Turbopack: fix persistent caching test case (#83170)
### What? The test case was broken and never tested if persistent caching was caching at all
1 parent 7b6136b commit e657c38

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

test/e2e/persistent-caching/my-loader.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = async function myLoader(source) {
2+
console.log('Loader is running!')
23
// Make webpack consider the build as large change which makes it persistent cache it sooner
34
await new Promise((resolve) => setTimeout(resolve, 2000))
45
return source.replace(/Timestamp/g, `Timestamp = ${Date.now()}`)

test/e2e/persistent-caching/next.config.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
const nextConfig = {
55
turbopack: {
66
rules: {
7-
'app/page.tsx': {
7+
'./app/page.tsx': {
88
loaders: ['./my-loader.js'],
99
},
10-
'pages/pages.tsx': {
10+
'./app/client/page.tsx': {
11+
loaders: ['./my-loader.js'],
12+
},
13+
'./pages/pages.tsx': {
1114
loaders: ['./my-loader.js'],
1215
},
1316
},
@@ -17,7 +20,7 @@ const nextConfig = {
1720
},
1821
webpack(config) {
1922
config.module.rules.push({
20-
test: /app\/page\.tsx|pages\/pages.tsx/,
23+
test: /app\/page\.tsx|app\/client\/page\.tsx|pages\/pages\.tsx/,
2124
use: ['./my-loader.js'],
2225
})
2326

test/e2e/persistent-caching/persistent-caching.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,19 @@ describe('persistent-caching', () => {
3939
{
4040
const browser = await next.browser('/')
4141
appTimestamp = await browser.elementByCss('main').text()
42+
expect(appTimestamp).toMatch(/Timestamp = \d+/)
4243
await browser.close()
4344
}
4445
{
4546
const browser = await next.browser('/client')
4647
appClientTimestamp = await browser.elementByCss('main').text()
48+
expect(appClientTimestamp).toMatch(/Timestamp = \d+/)
4749
await browser.close()
4850
}
4951
{
5052
const browser = await next.browser('/pages')
5153
pagesTimestamp = await browser.elementByCss('main').text()
54+
expect(pagesTimestamp).toMatch(/Timestamp = \d+/)
5255
await browser.close()
5356
}
5457
await restartCycle()

0 commit comments

Comments
 (0)