Skip to content

Commit 9fdf682

Browse files
committed
Skip all build tests in Turbopack
1 parent cf59fbc commit 9fdf682

File tree

122 files changed

+5227
-4790
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+5227
-4790
lines changed

test/integration/absolute-assetprefix/test/index.test.js

Lines changed: 90 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -19,103 +19,105 @@ let cdnAccessLog = []
1919
const nextConfig = new File(path.resolve(__dirname, '../next.config.js'))
2020

2121
describe('absolute assetPrefix with path prefix', () => {
22-
beforeAll(async () => {
23-
cdnPort = await findPort()
24-
// lightweight http proxy
25-
cdn = http.createServer((clientReq, clientRes) => {
26-
const proxyPath = clientReq.url.slice('/path-prefix'.length)
27-
cdnAccessLog.push(proxyPath)
28-
const proxyReq = http.request(
29-
{
30-
hostname: 'localhost',
31-
port: appPort,
32-
path: proxyPath,
33-
method: clientReq.method,
34-
headers: clientReq.headers,
35-
},
36-
(proxyRes) => {
37-
// cdn must be configured to allow requests from this origin
38-
proxyRes.headers[
39-
'Access-Control-Allow-Origin'
40-
] = `http://localhost:${appPort}`
41-
clientRes.writeHead(proxyRes.statusCode, proxyRes.headers)
42-
proxyRes.pipe(clientRes, { end: true })
43-
}
22+
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
23+
beforeAll(async () => {
24+
cdnPort = await findPort()
25+
// lightweight http proxy
26+
cdn = http.createServer((clientReq, clientRes) => {
27+
const proxyPath = clientReq.url.slice('/path-prefix'.length)
28+
cdnAccessLog.push(proxyPath)
29+
const proxyReq = http.request(
30+
{
31+
hostname: 'localhost',
32+
port: appPort,
33+
path: proxyPath,
34+
method: clientReq.method,
35+
headers: clientReq.headers,
36+
},
37+
(proxyRes) => {
38+
// cdn must be configured to allow requests from this origin
39+
proxyRes.headers[
40+
'Access-Control-Allow-Origin'
41+
] = `http://localhost:${appPort}`
42+
clientRes.writeHead(proxyRes.statusCode, proxyRes.headers)
43+
proxyRes.pipe(clientRes, { end: true })
44+
}
45+
)
46+
47+
clientReq.pipe(proxyReq, { end: true })
48+
})
49+
await new Promise((resolve) => cdn.listen(cdnPort, resolve))
50+
nextConfig.replace('__CDN_PORT__', cdnPort)
51+
await nextBuild(appDir)
52+
buildId = await fs.readFile(
53+
path.resolve(__dirname, '../.next/BUILD_ID'),
54+
'utf8'
4455
)
56+
appPort = await findPort()
57+
app = await nextStart(appDir, appPort)
58+
})
4559

46-
clientReq.pipe(proxyReq, { end: true })
60+
afterEach(() => {
61+
cdnAccessLog = []
4762
})
48-
await new Promise((resolve) => cdn.listen(cdnPort, resolve))
49-
nextConfig.replace('__CDN_PORT__', cdnPort)
50-
await nextBuild(appDir)
51-
buildId = await fs.readFile(
52-
path.resolve(__dirname, '../.next/BUILD_ID'),
53-
'utf8'
54-
)
55-
appPort = await findPort()
56-
app = await nextStart(appDir, appPort)
57-
})
5863

59-
afterEach(() => {
60-
cdnAccessLog = []
61-
})
64+
afterAll(() => killApp(app))
65+
afterAll(() => cdn.close())
66+
afterAll(() => nextConfig.restore())
6267

63-
afterAll(() => killApp(app))
64-
afterAll(() => cdn.close())
65-
afterAll(() => nextConfig.restore())
68+
it('should not fetch static data from a CDN', async () => {
69+
const browser = await webdriver(appPort, '/')
70+
await browser.waitForElementByCss('#about-link').click()
71+
const prop = await browser.waitForElementByCss('#prop').text()
72+
expect(prop).toBe('hello')
73+
expect(cdnAccessLog).not.toContain(`/_next/data/${buildId}/about.json`)
74+
})
6675

67-
it('should not fetch static data from a CDN', async () => {
68-
const browser = await webdriver(appPort, '/')
69-
await browser.waitForElementByCss('#about-link').click()
70-
const prop = await browser.waitForElementByCss('#prop').text()
71-
expect(prop).toBe('hello')
72-
expect(cdnAccessLog).not.toContain(`/_next/data/${buildId}/about.json`)
73-
})
76+
it('should fetch from cache correctly', async () => {
77+
const browser = await webdriver(appPort, '/')
78+
await browser.eval('window.clientSideNavigated = true')
79+
await browser.waitForElementByCss('#about-link').click()
80+
await browser.waitForElementByCss('#prop')
81+
await browser.back()
82+
await browser.waitForElementByCss('#about-link').click()
83+
const prop = await browser.waitForElementByCss('#prop').text()
84+
expect(prop).toBe('hello')
85+
expect(await browser.eval('window.clientSideNavigated')).toBe(true)
86+
expect(
87+
cdnAccessLog.filter(
88+
(path) => path === `/_next/data/${buildId}/about.json`
89+
)
90+
).toHaveLength(0)
91+
})
7492

75-
it('should fetch from cache correctly', async () => {
76-
const browser = await webdriver(appPort, '/')
77-
await browser.eval('window.clientSideNavigated = true')
78-
await browser.waitForElementByCss('#about-link').click()
79-
await browser.waitForElementByCss('#prop')
80-
await browser.back()
81-
await browser.waitForElementByCss('#about-link').click()
82-
const prop = await browser.waitForElementByCss('#prop').text()
83-
expect(prop).toBe('hello')
84-
expect(await browser.eval('window.clientSideNavigated')).toBe(true)
85-
expect(
86-
cdnAccessLog.filter(
87-
(path) => path === `/_next/data/${buildId}/about.json`
93+
it('should work with getStaticPaths prerendered', async () => {
94+
const browser = await webdriver(appPort, '/')
95+
await browser.waitForElementByCss('#gsp-prerender-link').click()
96+
const prop = await browser.waitForElementByCss('#prop').text()
97+
expect(prop).toBe('prerendered')
98+
expect(cdnAccessLog).not.toContain(
99+
`/_next/data/${buildId}/gsp-fallback/prerendered.json`
88100
)
89-
).toHaveLength(0)
90-
})
91-
92-
it('should work with getStaticPaths prerendered', async () => {
93-
const browser = await webdriver(appPort, '/')
94-
await browser.waitForElementByCss('#gsp-prerender-link').click()
95-
const prop = await browser.waitForElementByCss('#prop').text()
96-
expect(prop).toBe('prerendered')
97-
expect(cdnAccessLog).not.toContain(
98-
`/_next/data/${buildId}/gsp-fallback/prerendered.json`
99-
)
100-
})
101+
})
101102

102-
it('should work with getStaticPaths fallback', async () => {
103-
const browser = await webdriver(appPort, '/')
104-
await browser.waitForElementByCss('#gsp-fallback-link').click()
105-
const prop = await browser.waitForElementByCss('#prop').text()
106-
expect(prop).toBe('fallback')
107-
expect(cdnAccessLog).not.toContain(
108-
`/_next/data/${buildId}/gsp-fallback/fallback.json`
109-
)
110-
})
103+
it('should work with getStaticPaths fallback', async () => {
104+
const browser = await webdriver(appPort, '/')
105+
await browser.waitForElementByCss('#gsp-fallback-link').click()
106+
const prop = await browser.waitForElementByCss('#prop').text()
107+
expect(prop).toBe('fallback')
108+
expect(cdnAccessLog).not.toContain(
109+
`/_next/data/${buildId}/gsp-fallback/fallback.json`
110+
)
111+
})
111112

112-
it('should work with getServerSideProps', async () => {
113-
const browser = await webdriver(appPort, '/')
114-
await browser.waitForElementByCss('#gssp-link').click()
115-
const prop = await browser.waitForElementByCss('#prop').text()
116-
expect(prop).toBe('foo')
117-
expect(cdnAccessLog).not.toContain(
118-
`/_next/data/${buildId}/gssp.json?prop=foo`
119-
)
113+
it('should work with getServerSideProps', async () => {
114+
const browser = await webdriver(appPort, '/')
115+
await browser.waitForElementByCss('#gssp-link').click()
116+
const prop = await browser.waitForElementByCss('#prop').text()
117+
expect(prop).toBe('foo')
118+
expect(cdnAccessLog).not.toContain(
119+
`/_next/data/${buildId}/gssp.json?prop=foo`
120+
)
121+
})
120122
})
121123
})

test/integration/amp-export-validation/test/index.test.js

Lines changed: 90 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -13,114 +13,116 @@ const nextConfig = new File(join(appDir, 'next.config.js'))
1313
let buildOutput
1414

1515
describe('AMP Validation on Export', () => {
16-
beforeAll(async () => {
17-
const { stdout = '', stderr = '' } = await nextBuild(appDir, [], {
18-
stdout: true,
19-
stderr: true,
16+
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
17+
beforeAll(async () => {
18+
const { stdout = '', stderr = '' } = await nextBuild(appDir, [], {
19+
stdout: true,
20+
stderr: true,
21+
})
22+
await nextExport(appDir, { outdir: outDir }, { ignoreFail: true })
23+
buildOutput = stdout + stderr
2024
})
21-
await nextExport(appDir, { outdir: outDir }, { ignoreFail: true })
22-
buildOutput = stdout + stderr
23-
})
2425

25-
it('should have shown errors during build', async () => {
26-
expect(buildOutput).toMatch(
27-
/error.*The mandatory attribute 'height' is missing in tag 'amp-video'\./
28-
)
29-
})
26+
it('should have shown errors during build', async () => {
27+
expect(buildOutput).toMatch(
28+
/error.*The mandatory attribute 'height' is missing in tag 'amp-video'\./
29+
)
30+
})
3031

31-
it('should export AMP pages', async () => {
32-
const toCheck = ['first', 'second', 'third.amp']
33-
await Promise.all(
34-
toCheck.map(async (page) => {
35-
const content = await readFile(join(outDir, `${page}.html`))
36-
await validateAMP(content.toString())
37-
})
38-
)
39-
})
32+
it('should export AMP pages', async () => {
33+
const toCheck = ['first', 'second', 'third.amp']
34+
await Promise.all(
35+
toCheck.map(async (page) => {
36+
const content = await readFile(join(outDir, `${page}.html`))
37+
await validateAMP(content.toString())
38+
})
39+
)
40+
})
4041

41-
// this is now an error instead of a warning
42-
it.skip('shows AMP warning without throwing error', async () => {
43-
nextConfig.replace(
44-
'// exportPathMap',
45-
`exportPathMap: function(defaultMap) {
42+
// this is now an error instead of a warning
43+
it.skip('shows AMP warning without throwing error', async () => {
44+
nextConfig.replace(
45+
'// exportPathMap',
46+
`exportPathMap: function(defaultMap) {
4647
return {
4748
'/cat': { page: '/cat' },
4849
}
4950
},`
50-
)
51-
52-
try {
53-
const { stdout, stderr } = await runNextCommand(['export', appDir], {
54-
stdout: true,
55-
stderr: true,
56-
})
57-
expect(stdout).toMatch(
58-
/error.*The mandatory attribute 'height' is missing in tag 'amp-video'\./
59-
)
60-
await expect(access(join(outDir, 'cat.html'))).resolves.toBe(undefined)
61-
await expect(stderr).not.toMatch(
62-
/Found conflicting amp tag "meta" with conflicting prop name="viewport"/
6351
)
64-
} finally {
65-
nextConfig.restore()
66-
}
67-
})
6852

69-
// img instead of amp-img no longer shows a warning
70-
it.skip('throws error on AMP error', async () => {
71-
nextConfig.replace(
72-
'// exportPathMap',
73-
`exportPathMap: function(defaultMap) {
53+
try {
54+
const { stdout, stderr } = await runNextCommand(['export', appDir], {
55+
stdout: true,
56+
stderr: true,
57+
})
58+
expect(stdout).toMatch(
59+
/error.*The mandatory attribute 'height' is missing in tag 'amp-video'\./
60+
)
61+
await expect(access(join(outDir, 'cat.html'))).resolves.toBe(undefined)
62+
await expect(stderr).not.toMatch(
63+
/Found conflicting amp tag "meta" with conflicting prop name="viewport"/
64+
)
65+
} finally {
66+
nextConfig.restore()
67+
}
68+
})
69+
70+
// img instead of amp-img no longer shows a warning
71+
it.skip('throws error on AMP error', async () => {
72+
nextConfig.replace(
73+
'// exportPathMap',
74+
`exportPathMap: function(defaultMap) {
7475
return {
7576
'/dog': { page: '/dog' },
7677
}
7778
},`
78-
)
79-
80-
try {
81-
const { stdout, stderr } = await runNextCommand(['export', appDir], {
82-
stdout: true,
83-
stderr: true,
84-
})
85-
expect(stdout).toMatch(
86-
/error.*The parent tag of tag 'img' is 'div', but it can only be 'i-amphtml-sizer-intrinsic'\./
87-
)
88-
await expect(access(join(outDir, 'dog.html'))).resolves.toBe(undefined)
89-
await expect(stderr).not.toMatch(
90-
/Found conflicting amp tag "meta" with conflicting prop name="viewport"/
9179
)
92-
} finally {
93-
nextConfig.restore()
94-
}
95-
})
9680

97-
// img instead of amp-img no longer shows a warning
98-
it.skip('shows warning and error when throwing error', async () => {
99-
nextConfig.replace(
100-
'// exportPathMap',
101-
`exportPathMap: function(defaultMap) {
81+
try {
82+
const { stdout, stderr } = await runNextCommand(['export', appDir], {
83+
stdout: true,
84+
stderr: true,
85+
})
86+
expect(stdout).toMatch(
87+
/error.*The parent tag of tag 'img' is 'div', but it can only be 'i-amphtml-sizer-intrinsic'\./
88+
)
89+
await expect(access(join(outDir, 'dog.html'))).resolves.toBe(undefined)
90+
await expect(stderr).not.toMatch(
91+
/Found conflicting amp tag "meta" with conflicting prop name="viewport"/
92+
)
93+
} finally {
94+
nextConfig.restore()
95+
}
96+
})
97+
98+
// img instead of amp-img no longer shows a warning
99+
it.skip('shows warning and error when throwing error', async () => {
100+
nextConfig.replace(
101+
'// exportPathMap',
102+
`exportPathMap: function(defaultMap) {
102103
return {
103104
'/dog-cat': { page: '/dog-cat' },
104105
}
105106
},`
106-
)
107-
108-
try {
109-
const { stdout, stderr } = await runNextCommand(['export', appDir], {
110-
stdout: true,
111-
stderr: true,
112-
})
113-
expect(stdout).toMatch(
114-
/error.*The parent tag of tag 'img' is 'div', but it can only be 'i-amphtml-sizer-intrinsic'\./
115107
)
116-
await expect(access(join(outDir, 'dog-cat.html'))).resolves.toBe(
117-
undefined
118-
)
119-
await expect(stderr).not.toMatch(
120-
/Found conflicting amp tag "meta" with conflicting prop name="viewport"/
121-
)
122-
} finally {
123-
nextConfig.restore()
124-
}
108+
109+
try {
110+
const { stdout, stderr } = await runNextCommand(['export', appDir], {
111+
stdout: true,
112+
stderr: true,
113+
})
114+
expect(stdout).toMatch(
115+
/error.*The parent tag of tag 'img' is 'div', but it can only be 'i-amphtml-sizer-intrinsic'\./
116+
)
117+
await expect(access(join(outDir, 'dog-cat.html'))).resolves.toBe(
118+
undefined
119+
)
120+
await expect(stderr).not.toMatch(
121+
/Found conflicting amp tag "meta" with conflicting prop name="viewport"/
122+
)
123+
} finally {
124+
nextConfig.restore()
125+
}
126+
})
125127
})
126128
})

0 commit comments

Comments
 (0)