Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 63 additions & 47 deletions test/integration/mixed-ssg-serverprops-error/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,53 +13,66 @@ describe('Mixed getStaticProps and getServerSideProps error', () => {
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
() => {
it('should error with getStaticProps but no default export', async () => {
// TODO: remove after investigating why dev swc build fails here
await fs.writeFile(
join(appDir, '.babelrc'),
'{ "presets": ["next/babel"] }'
)
await fs.move(indexPage, indexPageBak)
await fs.writeFile(
indexPage,
`
// Uses Babel, not supported in Turbopack.
;(process.env.TURBOPACK ? it.skip : it)(
'should error with getStaticProps but no default export',
async () => {
// TODO: remove after investigating why dev swc build fails here
await fs.writeFile(
join(appDir, '.babelrc'),
'{ "presets": ["next/babel"] }'
)
await fs.move(indexPage, indexPageBak)
await fs.writeFile(
indexPage,
`
export function getStaticProps() {
return {
props: {}
}
}
`
)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
await fs.remove(join(appDir, '.babelrc'))
await fs.remove(indexPage)
await fs.move(indexPageBak, indexPage)
expect(stderr).toContain(
'found page without a React Component as default export in'
)
})
)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
await fs.remove(join(appDir, '.babelrc'))
await fs.remove(indexPage)
await fs.move(indexPageBak, indexPage)
// eslint-disable-next-line jest/no-standalone-expect
expect(stderr).toContain(
'found page without a React Component as default export in'
)
}
)

it('should error when exporting both getStaticProps and getServerSideProps', async () => {
// TODO: remove after investigating why dev swc build fails here
await fs.writeFile(
join(appDir, '.babelrc'),
'{ "presets": ["next/babel"] }'
)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
await fs.remove(join(appDir, '.babelrc'))
expect(stderr).toContain(SERVER_PROPS_SSG_CONFLICT)
})
// Uses Babel, not supported in Turbopack.
;(process.env.TURBOPACK ? it.skip : it)(
'should error when exporting both getStaticProps and getServerSideProps',
async () => {
// TODO: remove after investigating why dev swc build fails here
await fs.writeFile(
join(appDir, '.babelrc'),
'{ "presets": ["next/babel"] }'
)
const { stderr } = await nextBuild(appDir, [], { stderr: true })
await fs.remove(join(appDir, '.babelrc'))
// eslint-disable-next-line jest/no-standalone-expect
expect(stderr).toContain(SERVER_PROPS_SSG_CONFLICT)
}
)

it('should error when exporting both getStaticPaths and getServerSideProps', async () => {
// TODO: remove after investigating why dev swc build fails here
await fs.writeFile(
join(appDir, '.babelrc'),
'{ "presets": ["next/babel"] }'
)
await fs.move(indexPage, indexPageBak)
await fs.writeFile(
indexPage,
`
// Uses Babel, not supported in Turbopack.
;(process.env.TURBOPACK ? it.skip : it)(
'should error when exporting both getStaticPaths and getServerSideProps',
async () => {
// TODO: remove after investigating why dev swc build fails here
await fs.writeFile(
join(appDir, '.babelrc'),
'{ "presets": ["next/babel"] }'
)
await fs.move(indexPage, indexPageBak)
await fs.writeFile(
indexPage,
`
export const getStaticPaths = async () => {
return {
props: { world: 'world' }, fallback: true
Expand All @@ -74,14 +87,17 @@ describe('Mixed getStaticProps and getServerSideProps error', () => {

export default ({ world }) => <p>Hello {world}</p>
`
)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
await fs.remove(join(appDir, '.babelrc'))
await fs.remove(indexPage)
await fs.move(indexPageBak, indexPage)
expect(code).toBe(1)
expect(stderr).toContain(SERVER_PROPS_SSG_CONFLICT)
})
)
const { stderr, code } = await nextBuild(appDir, [], { stderr: true })
await fs.remove(join(appDir, '.babelrc'))
await fs.remove(indexPage)
await fs.move(indexPageBak, indexPage)
// eslint-disable-next-line jest/no-standalone-expect
expect(code).toBe(1)
// eslint-disable-next-line jest/no-standalone-expect
expect(stderr).toContain(SERVER_PROPS_SSG_CONFLICT)
}
)

it('should error when exporting getStaticPaths on a non-dynamic page', async () => {
await fs.move(indexPage, indexPageBak)
Expand Down
38 changes: 21 additions & 17 deletions test/production/next-font/babel-unsupported.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@ import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'e2e-utils'
import { join } from 'path'

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

beforeAll(async () => {
next = await createNext({
skipStart: true,
files: new FileRef(join(__dirname, 'babel-unsupported')),
beforeAll(async () => {
next = await createNext({
skipStart: true,
files: new FileRef(join(__dirname, 'babel-unsupported')),
})
})
})
afterAll(() => next.destroy())
afterAll(() => next.destroy())

test('Build error when using babel', async () => {
await expect(next.start()).rejects.toThrow(
'next build failed with code/signal 1'
)
expect(next.cliOutput).toMatch(
/"next\/font" requires SWC although Babel is being used due to a custom babel config being present./
)
})
})
test('Build error when using babel', async () => {
await expect(next.start()).rejects.toThrow(
'next build failed with code/signal 1'
)
expect(next.cliOutput).toMatch(
/"next\/font" requires SWC although Babel is being used due to a custom babel config being present./
)
})
}
)
8 changes: 4 additions & 4 deletions test/turbopack-build-tests-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -12669,12 +12669,12 @@
"passed": [
"Mixed getStaticProps and getServerSideProps error production mode should error when exporting getStaticPaths on a non-dynamic page"
],
"failed": [
"failed": [],
"pending": [
"Mixed getStaticProps and getServerSideProps error production mode should error when exporting both getStaticPaths and getServerSideProps",
"Mixed getStaticProps and getServerSideProps error production mode should error when exporting both getStaticProps and getServerSideProps",
"Mixed getStaticProps and getServerSideProps error production mode should error with getStaticProps but no default export"
],
"pending": [],
"flakey": [],
"runtimeError": false
},
Expand Down Expand Up @@ -15956,8 +15956,8 @@
},
"test/production/next-font/babel-unsupported.test.ts": {
"passed": [],
"failed": ["@next/fon babel unsupported Build error when using babel"],
"pending": [],
"failed": [],
"pending": ["@next/font babel unsupported Build error when using babel"],
"flakey": [],
"runtimeError": false
},
Expand Down