Skip to content

Commit 4e435e2

Browse files
authoredOct 16, 2023
Skip webpack specific tests in Turbopack test run (#56877)
Looked for `webpack(config` in the test suites and disabled the ones that are testing webpack specifically. There are a few more that are not skipped as they should be implemented for Turbopack.
1 parent 5b52e77 commit 4e435e2

File tree

5 files changed

+137
-114
lines changed

5 files changed

+137
-114
lines changed
 

‎test/integration/broken-webpack-plugin/test/index.test.js

+29-25
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,36 @@ const appDir = join(__dirname, '../')
99
let appPort
1010
let app
1111

12-
describe('Handles a broken webpack plugin (precompile)', () => {
13-
let stderr = ''
14-
beforeAll(async () => {
15-
appPort = await findPort()
16-
app = await launchApp(appDir, appPort, {
17-
stderr: true,
18-
nextStart: true,
19-
onStderr(text) {
20-
stderr += text
21-
},
12+
// Skipped as it's not relevant to Turbopack.
13+
;(process.env.TURBOPACK ? describe.skip : describe)(
14+
'Handles a broken webpack plugin (precompile)',
15+
() => {
16+
let stderr = ''
17+
beforeAll(async () => {
18+
appPort = await findPort()
19+
app = await launchApp(appDir, appPort, {
20+
stderr: true,
21+
nextStart: true,
22+
onStderr(text) {
23+
stderr += text
24+
},
25+
})
26+
await waitPort({
27+
host: 'localhost',
28+
port: appPort,
29+
})
2230
})
23-
await waitPort({
24-
host: 'localhost',
25-
port: appPort,
26-
})
27-
})
28-
afterAll(() => killApp(app))
31+
afterAll(() => killApp(app))
2932

30-
beforeEach(() => {
31-
stderr = ''
32-
})
33+
beforeEach(() => {
34+
stderr = ''
35+
})
3336

34-
it('should render error correctly', async () => {
35-
const text = await renderViaHTTP(appPort, '/')
36-
expect(text).toContain('Internal Server Error')
37+
it('should render error correctly', async () => {
38+
const text = await renderViaHTTP(appPort, '/')
39+
expect(text).toContain('Internal Server Error')
3740

38-
expect(stderr).toMatch('Error: oops')
39-
})
40-
})
41+
expect(stderr).toMatch('Error: oops')
42+
})
43+
}
44+
)

‎test/integration/chunking/test/index.test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ const existsChunkNamed = (name) => {
2222
return chunks.some((chunk) => new RegExp(name).test(chunk))
2323
}
2424

25-
describe('Chunking', () => {
25+
// Skipped as it uses webpack internals / stats.json.
26+
;(process.env.TURBOPACK ? describe.skip : describe)('Chunking', () => {
2627
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
2728
beforeAll(async () => {
2829
try {

‎test/integration/config-devtool-dev/test/index.test.js

+34-30
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,33 @@ import { join } from 'path'
1313

1414
const appDir = join(__dirname, '../')
1515

16-
describe('devtool set in development mode in next config', () => {
17-
it('should warn and revert when a devtool is set in development mode', async () => {
18-
let stderr = ''
19-
20-
const appPort = await findPort()
21-
const app = await launchApp(appDir, appPort, {
22-
env: { __NEXT_TEST_WITH_DEVTOOL: true },
23-
onStderr(msg) {
24-
stderr += msg || ''
25-
},
26-
})
27-
28-
const found = await check(
29-
() => stderr,
30-
/Reverting webpack devtool to /,
31-
false
32-
)
33-
34-
const browser = await webdriver(appPort, '/')
35-
expect(await hasRedbox(browser, true)).toBe(true)
36-
if (process.platform === 'win32') {
37-
// TODO: add win32 snapshot
38-
} else {
39-
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
16+
// Webpack specific config tests.
17+
;(process.env.TURBOPACK ? describe.skip : describe)(
18+
'devtool set in development mode in next config',
19+
() => {
20+
it('should warn and revert when a devtool is set in development mode', async () => {
21+
let stderr = ''
22+
23+
const appPort = await findPort()
24+
const app = await launchApp(appDir, appPort, {
25+
env: { __NEXT_TEST_WITH_DEVTOOL: true },
26+
onStderr(msg) {
27+
stderr += msg || ''
28+
},
29+
})
30+
31+
const found = await check(
32+
() => stderr,
33+
/Reverting webpack devtool to /,
34+
false
35+
)
36+
37+
const browser = await webdriver(appPort, '/')
38+
expect(await hasRedbox(browser, true)).toBe(true)
39+
if (process.platform === 'win32') {
40+
// TODO: add win32 snapshot
41+
} else {
42+
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
4043
"pages/index.js (5:10) @ eval
4144
4245
3 | export default function Index(props) {
@@ -47,10 +50,11 @@ describe('devtool set in development mode in next config', () => {
4750
7 | return <div>Index Page</div>
4851
8 | }"
4952
`)
50-
}
51-
await browser.close()
53+
}
54+
await browser.close()
5255

53-
await killApp(app)
54-
expect(found).toBeTruthy()
55-
})
56-
})
56+
await killApp(app)
57+
expect(found).toBeTruthy()
58+
})
59+
}
60+
)

‎test/integration/next-image-legacy/svgo-webpack/test/index.test.ts

+33-26
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,40 @@ let appPort
1414
let app
1515
let devOutput
1616

17-
describe('svgo-webpack with Image Component', () => {
18-
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
19-
it('should not fail to build invalid usage of the Image component', async () => {
20-
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
21-
expect(stderr).toBeFalsy()
22-
expect(code).toBe(0)
23-
})
24-
})
17+
// Skip as this is a webpack specific test.
18+
;(process.env.TURBOPACK ? describe.skip : describe)(
19+
'svgo-webpack with Image Component',
20+
() => {
21+
;(process.env.TURBOPACK ? describe.skip : describe)(
22+
'production mode',
23+
() => {
24+
it('should not fail to build invalid usage of the Image component', async () => {
25+
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
26+
expect(stderr).toBeFalsy()
27+
expect(code).toBe(0)
28+
})
29+
}
30+
)
2531

26-
describe('development mode', () => {
27-
beforeAll(async () => {
28-
devOutput = { stdout: '', stderr: '' }
29-
appPort = await findPort()
30-
app = await launchApp(appDir, appPort, {
31-
onStdout: (msg) => {
32-
devOutput.stdout += msg
33-
},
34-
onStderr: (msg) => {
35-
devOutput.stderr += msg
36-
},
32+
describe('development mode', () => {
33+
beforeAll(async () => {
34+
devOutput = { stdout: '', stderr: '' }
35+
appPort = await findPort()
36+
app = await launchApp(appDir, appPort, {
37+
onStdout: (msg) => {
38+
devOutput.stdout += msg
39+
},
40+
onStderr: (msg) => {
41+
devOutput.stderr += msg
42+
},
43+
})
3744
})
38-
})
39-
afterAll(() => killApp(app))
45+
afterAll(() => killApp(app))
4046

41-
it('should print error when invalid Image usage', async () => {
42-
await renderViaHTTP(appPort, '/', {})
43-
expect(devOutput.stderr).toBeFalsy()
47+
it('should print error when invalid Image usage', async () => {
48+
await renderViaHTTP(appPort, '/', {})
49+
expect(devOutput.stderr).toBeFalsy()
50+
})
4451
})
45-
})
46-
})
52+
}
53+
)

‎test/integration/next-image-new/svgo-webpack/test/index.test.ts

+39-32
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,46 @@ let appPort
1414
let app
1515
let devOutput
1616

17-
describe('svgo-webpack with Image Component', () => {
18-
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
19-
it('should not fail to build invalid usage of the Image component', async () => {
20-
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
21-
const errors = stderr
22-
.split('\n')
23-
.filter((line) => line && !line.trim().startsWith('⚠️'))
24-
expect(errors).toEqual([])
25-
expect(code).toBe(0)
26-
})
27-
})
17+
// Skip as this is a webpack specific test.
18+
;(process.env.TURBOPACK ? describe.skip : describe)(
19+
'svgo-webpack with Image Component',
20+
() => {
21+
;(process.env.TURBOPACK ? describe.skip : describe)(
22+
'production mode',
23+
() => {
24+
it('should not fail to build invalid usage of the Image component', async () => {
25+
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
26+
const errors = stderr
27+
.split('\n')
28+
.filter((line) => line && !line.trim().startsWith('⚠️'))
29+
expect(errors).toEqual([])
30+
expect(code).toBe(0)
31+
})
32+
}
33+
)
2834

29-
describe('development mode', () => {
30-
beforeAll(async () => {
31-
devOutput = { stdout: '', stderr: '' }
32-
appPort = await findPort()
33-
app = await launchApp(appDir, appPort, {
34-
onStdout: (msg) => {
35-
devOutput.stdout += msg
36-
},
37-
onStderr: (msg) => {
38-
devOutput.stderr += msg
39-
},
35+
describe('development mode', () => {
36+
beforeAll(async () => {
37+
devOutput = { stdout: '', stderr: '' }
38+
appPort = await findPort()
39+
app = await launchApp(appDir, appPort, {
40+
onStdout: (msg) => {
41+
devOutput.stdout += msg
42+
},
43+
onStderr: (msg) => {
44+
devOutput.stderr += msg
45+
},
46+
})
4047
})
41-
})
42-
afterAll(() => killApp(app))
48+
afterAll(() => killApp(app))
4349

44-
it('should print error when invalid Image usage', async () => {
45-
await renderViaHTTP(appPort, '/', {})
46-
const errors = devOutput.stderr
47-
.split('\n')
48-
.filter((line) => line && !line.trim().startsWith('⚠️'))
49-
expect(errors).toEqual([])
50+
it('should print error when invalid Image usage', async () => {
51+
await renderViaHTTP(appPort, '/', {})
52+
const errors = devOutput.stderr
53+
.split('\n')
54+
.filter((line) => line && !line.trim().startsWith('⚠️'))
55+
expect(errors).toEqual([])
56+
})
5057
})
51-
})
52-
})
58+
}
59+
)

0 commit comments

Comments
 (0)
Please sign in to comment.