Skip to content

Commit 906b880

Browse files
authored
Turbopack build: Skip babel specific tests (#67912)
Ensures the tests that depend on `.babelrc` are skipped. This is not supported in Turbopack without adding the babel-loader, and then `next/babel` is not needed. <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # -->
1 parent 23cd7a0 commit 906b880

File tree

3 files changed

+88
-68
lines changed

3 files changed

+88
-68
lines changed

test/integration/mixed-ssg-serverprops-error/test/index.test.js

Lines changed: 63 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,53 +13,66 @@ describe('Mixed getStaticProps and getServerSideProps error', () => {
1313
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
1414
'production mode',
1515
() => {
16-
it('should error with getStaticProps but no default export', async () => {
17-
// TODO: remove after investigating why dev swc build fails here
18-
await fs.writeFile(
19-
join(appDir, '.babelrc'),
20-
'{ "presets": ["next/babel"] }'
21-
)
22-
await fs.move(indexPage, indexPageBak)
23-
await fs.writeFile(
24-
indexPage,
25-
`
16+
// Uses Babel, not supported in Turbopack.
17+
;(process.env.TURBOPACK ? it.skip : it)(
18+
'should error with getStaticProps but no default export',
19+
async () => {
20+
// TODO: remove after investigating why dev swc build fails here
21+
await fs.writeFile(
22+
join(appDir, '.babelrc'),
23+
'{ "presets": ["next/babel"] }'
24+
)
25+
await fs.move(indexPage, indexPageBak)
26+
await fs.writeFile(
27+
indexPage,
28+
`
2629
export function getStaticProps() {
2730
return {
2831
props: {}
2932
}
3033
}
3134
`
32-
)
33-
const { stderr } = await nextBuild(appDir, [], { stderr: true })
34-
await fs.remove(join(appDir, '.babelrc'))
35-
await fs.remove(indexPage)
36-
await fs.move(indexPageBak, indexPage)
37-
expect(stderr).toContain(
38-
'found page without a React Component as default export in'
39-
)
40-
})
35+
)
36+
const { stderr } = await nextBuild(appDir, [], { stderr: true })
37+
await fs.remove(join(appDir, '.babelrc'))
38+
await fs.remove(indexPage)
39+
await fs.move(indexPageBak, indexPage)
40+
// eslint-disable-next-line jest/no-standalone-expect
41+
expect(stderr).toContain(
42+
'found page without a React Component as default export in'
43+
)
44+
}
45+
)
4146

42-
it('should error when exporting both getStaticProps and getServerSideProps', async () => {
43-
// TODO: remove after investigating why dev swc build fails here
44-
await fs.writeFile(
45-
join(appDir, '.babelrc'),
46-
'{ "presets": ["next/babel"] }'
47-
)
48-
const { stderr } = await nextBuild(appDir, [], { stderr: true })
49-
await fs.remove(join(appDir, '.babelrc'))
50-
expect(stderr).toContain(SERVER_PROPS_SSG_CONFLICT)
51-
})
47+
// Uses Babel, not supported in Turbopack.
48+
;(process.env.TURBOPACK ? it.skip : it)(
49+
'should error when exporting both getStaticProps and getServerSideProps',
50+
async () => {
51+
// TODO: remove after investigating why dev swc build fails here
52+
await fs.writeFile(
53+
join(appDir, '.babelrc'),
54+
'{ "presets": ["next/babel"] }'
55+
)
56+
const { stderr } = await nextBuild(appDir, [], { stderr: true })
57+
await fs.remove(join(appDir, '.babelrc'))
58+
// eslint-disable-next-line jest/no-standalone-expect
59+
expect(stderr).toContain(SERVER_PROPS_SSG_CONFLICT)
60+
}
61+
)
5262

53-
it('should error when exporting both getStaticPaths and getServerSideProps', async () => {
54-
// TODO: remove after investigating why dev swc build fails here
55-
await fs.writeFile(
56-
join(appDir, '.babelrc'),
57-
'{ "presets": ["next/babel"] }'
58-
)
59-
await fs.move(indexPage, indexPageBak)
60-
await fs.writeFile(
61-
indexPage,
62-
`
63+
// Uses Babel, not supported in Turbopack.
64+
;(process.env.TURBOPACK ? it.skip : it)(
65+
'should error when exporting both getStaticPaths and getServerSideProps',
66+
async () => {
67+
// TODO: remove after investigating why dev swc build fails here
68+
await fs.writeFile(
69+
join(appDir, '.babelrc'),
70+
'{ "presets": ["next/babel"] }'
71+
)
72+
await fs.move(indexPage, indexPageBak)
73+
await fs.writeFile(
74+
indexPage,
75+
`
6376
export const getStaticPaths = async () => {
6477
return {
6578
props: { world: 'world' }, fallback: true
@@ -74,14 +87,17 @@ describe('Mixed getStaticProps and getServerSideProps error', () => {
7487
7588
export default ({ world }) => <p>Hello {world}</p>
7689
`
77-
)
78-
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
79-
await fs.remove(join(appDir, '.babelrc'))
80-
await fs.remove(indexPage)
81-
await fs.move(indexPageBak, indexPage)
82-
expect(code).toBe(1)
83-
expect(stderr).toContain(SERVER_PROPS_SSG_CONFLICT)
84-
})
90+
)
91+
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
92+
await fs.remove(join(appDir, '.babelrc'))
93+
await fs.remove(indexPage)
94+
await fs.move(indexPageBak, indexPage)
95+
// eslint-disable-next-line jest/no-standalone-expect
96+
expect(code).toBe(1)
97+
// eslint-disable-next-line jest/no-standalone-expect
98+
expect(stderr).toContain(SERVER_PROPS_SSG_CONFLICT)
99+
}
100+
)
85101

86102
it('should error when exporting getStaticPaths on a non-dynamic page', async () => {
87103
await fs.move(indexPage, indexPageBak)

test/production/next-font/babel-unsupported.test.ts

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,27 @@ import { createNext, FileRef } from 'e2e-utils'
22
import { NextInstance } from 'e2e-utils'
33
import { join } from 'path'
44

5-
describe('@next/fon babel unsupported', () => {
6-
let next: NextInstance
5+
// Turbopack does not support `.babelrc`. So this test is not relevant for Turbopack.
6+
;(process.env.TURBOPACK ? describe.skip : describe)(
7+
'@next/font babel unsupported',
8+
() => {
9+
let next: NextInstance
710

8-
beforeAll(async () => {
9-
next = await createNext({
10-
skipStart: true,
11-
files: new FileRef(join(__dirname, 'babel-unsupported')),
11+
beforeAll(async () => {
12+
next = await createNext({
13+
skipStart: true,
14+
files: new FileRef(join(__dirname, 'babel-unsupported')),
15+
})
1216
})
13-
})
14-
afterAll(() => next.destroy())
17+
afterAll(() => next.destroy())
1518

16-
test('Build error when using babel', async () => {
17-
await expect(next.start()).rejects.toThrow(
18-
'next build failed with code/signal 1'
19-
)
20-
expect(next.cliOutput).toMatch(
21-
/"next\/font" requires SWC although Babel is being used due to a custom babel config being present./
22-
)
23-
})
24-
})
19+
test('Build error when using babel', async () => {
20+
await expect(next.start()).rejects.toThrow(
21+
'next build failed with code/signal 1'
22+
)
23+
expect(next.cliOutput).toMatch(
24+
/"next\/font" requires SWC although Babel is being used due to a custom babel config being present./
25+
)
26+
})
27+
}
28+
)

test/turbopack-build-tests-manifest.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12669,12 +12669,12 @@
1266912669
"passed": [
1267012670
"Mixed getStaticProps and getServerSideProps error production mode should error when exporting getStaticPaths on a non-dynamic page"
1267112671
],
12672-
"failed": [
12672+
"failed": [],
12673+
"pending": [
1267312674
"Mixed getStaticProps and getServerSideProps error production mode should error when exporting both getStaticPaths and getServerSideProps",
1267412675
"Mixed getStaticProps and getServerSideProps error production mode should error when exporting both getStaticProps and getServerSideProps",
1267512676
"Mixed getStaticProps and getServerSideProps error production mode should error with getStaticProps but no default export"
1267612677
],
12677-
"pending": [],
1267812678
"flakey": [],
1267912679
"runtimeError": false
1268012680
},
@@ -15956,8 +15956,8 @@
1595615956
},
1595715957
"test/production/next-font/babel-unsupported.test.ts": {
1595815958
"passed": [],
15959-
"failed": ["@next/fon babel unsupported Build error when using babel"],
15960-
"pending": [],
15959+
"failed": [],
15960+
"pending": ["@next/font babel unsupported Build error when using babel"],
1596115961
"flakey": [],
1596215962
"runtimeError": false
1596315963
},

0 commit comments

Comments
 (0)