Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
- Loading branch information
Showing
4 changed files
with
42 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
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,18 @@ | ||
import App, { AppContext, AppProps } from 'next/app'; | ||
|
||
const MyApp = ({ Component, pageProps }: AppProps) => { | ||
return <Component {...pageProps} />; | ||
}; | ||
|
||
MyApp.getInitialProps = async (appContext: AppContext) => { | ||
// This simulates user misconfiguration. Users should always call `App.getInitialProps(appContext)`, but they don't, | ||
// so we have a test for this so we don't break their apps. | ||
if (appContext.ctx.pathname === '/faultyAppGetInitialProps') { | ||
return {}; | ||
} | ||
|
||
const appProps = await App.getInitialProps(appContext); | ||
return { ...appProps }; | ||
}; | ||
|
||
export default MyApp; |
4 changes: 4 additions & 0 deletions
4
packages/nextjs/test/integration/pages/faultyAppGetInitialProps.tsx
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,4 @@ | ||
// See _app.tsx for more information why this file exists. | ||
const Page = (): JSX.Element => <h1>Hello World!</h1>; | ||
|
||
export default Page; |
11 changes: 11 additions & 0 deletions
11
packages/nextjs/test/integration/test/client/faultyAppGetInitialPropsConfiguration.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,11 @@ | ||
const expect = require('expect'); | ||
|
||
// This test verifies that a faulty configuration of `getInitialProps` in `_app` will not cause our | ||
// auto - wrapping / instrumentation to throw an error. | ||
// See `_app.tsx` for more information. | ||
|
||
module.exports = async ({ page, url }) => { | ||
await page.goto(`${url}/faultyAppGetInitialProps`); | ||
const serverErrorText = await page.$x('//*[contains(text(), "Internal Server Error")]'); | ||
expect(serverErrorText).toHaveLength(0); | ||
}; |