forked from vercel/next.js
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add conflicting app and page error (vercel#41099)
This adds a proper error when we detect conflicting app and page paths. Fixes: https://vercel.slack.com/archives/C043ANYDB24/p1664678172389449 ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` Co-authored-by: Sukka <isukkaw@gmail.com>
- Loading branch information
Showing
8 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
test/integration/conflicting-app-page-error/app/another/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page(props) { | ||
return <p>another app</p> | ||
} |
3 changes: 3 additions & 0 deletions
3
test/integration/conflicting-app-page-error/app/hello/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page(props) { | ||
return <p>hello app</p> | ||
} |
3 changes: 3 additions & 0 deletions
3
test/integration/conflicting-app-page-error/app/non-conflict/page.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page(props) { | ||
return <p>another app</p> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
experimental: { | ||
appDir: true, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page(props) { | ||
return <p>another page</p> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Page(props) { | ||
return <p>hello page</p> | ||
} |
20 changes: 20 additions & 0 deletions
20
test/integration/conflicting-app-page-error/test/index.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* eslint-env jest */ | ||
|
||
import path from 'path' | ||
import { nextBuild } from 'next-test-utils' | ||
|
||
const appDir = path.join(__dirname, '..') | ||
|
||
describe('conflict between app file and page file', () => { | ||
it('errors during build', async () => { | ||
const conflicts = ['/hello', '/another'] | ||
const results = await nextBuild(appDir, [], { stdout: true, stderr: true }) | ||
const output = results.stdout + results.stderr | ||
expect(output).toMatch(/Conflicting app and page files were found/) | ||
|
||
for (const conflict of conflicts) { | ||
expect(output).toContain(conflict) | ||
} | ||
expect(output).not.toContain('/non-conflict') | ||
}) | ||
}) |