forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break up large test suites (vercel#50458)
This breaks up some of our longest running tests which allows more parallelizing of the tests. This also moves turbopack tests filtering back to an allow list as it is running a lot of unrelated tests currently which isn't ideal. We should only be running against tests that are explicitly testing turbopack e.g. build tests should not be duplicated in the turbopack group. ```sh test/integration/css/test/group-1.test.js: 762.655 test/integration/edge-runtime-module-errors/test/index.test.js: 695.309 test/integration/css/test/group-2.test.js: 671.848 test/integration/i18n-support/test/index.test.js: 518.173 test/integration/scss-modules/test/index.test.js: 451.704 test/integration/css-features/test/index.test.js: 417.318 test/integration/css-modules/test/index.test.js: 403.405 test/integration/eslint/test/index.test.js: 381.563 test/integration/500-page/test/index.test.js: 371.134 test/integration/telemetry/test/index.test.js: 367.691 test/development/acceptance-app/ReactRefreshLogBox.test.ts: 335.878 test/integration/create-next-app/templates.test.ts: 334.01 test/integration/scss/test/group-2.test.js: 327.255 test/integration/scss/test/group-1.test.js: 318.574 test/integration/edge-runtime-configurable-guards/test/index.test.js: 313.834 test/e2e/instrumentation-hook/instrumentation-hook.test.ts: 294.618 test/development/acceptance-app/error-recovery.test.ts: 283.355 test/e2e/app-dir/app/vercel-speed-insights.test.ts: 278.242 test/integration/create-next-app/index.test.ts: 272.442 ```
- Loading branch information
Showing
43 changed files
with
5,820 additions
and
5,688 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
739 changes: 265 additions & 474 deletions
739
packages/next-swc/crates/next-dev-tests/tests-manifest.js
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,238 @@ | ||
/* eslint-env jest */ | ||
|
||
import fs from 'fs-extra' | ||
import { join } from 'path' | ||
import { | ||
killApp, | ||
findPort, | ||
launchApp, | ||
nextStart, | ||
nextBuild, | ||
renderViaHTTP, | ||
waitFor, | ||
} from 'next-test-utils' | ||
|
||
const appDir = join(__dirname, '../') | ||
const pages500 = join(appDir, 'pages/500.js') | ||
const pagesApp = join(appDir, 'pages/_app.js') | ||
const pagesError = join(appDir, 'pages/_error.js') | ||
const gip500Err = | ||
/`pages\/500` can not have getInitialProps\/getServerSideProps/ | ||
|
||
let appPort | ||
let app | ||
|
||
it('does not show error with getStaticProps in pages/500 build', async () => { | ||
await fs.move(pages500, `${pages500}.bak`) | ||
await fs.writeFile( | ||
pages500, | ||
` | ||
const page = () => 'custom 500 page' | ||
export const getStaticProps = () => ({ props: { a: 'b' } }) | ||
export default page | ||
` | ||
) | ||
await fs.remove(join(appDir, '.next')) | ||
const { stderr, code } = await nextBuild(appDir, [], { stderr: true }) | ||
await fs.remove(pages500) | ||
await fs.move(`${pages500}.bak`, pages500) | ||
|
||
expect(stderr).not.toMatch(gip500Err) | ||
expect(code).toBe(0) | ||
}) | ||
|
||
it('does not show error with getStaticProps in pages/500 dev', async () => { | ||
await fs.move(pages500, `${pages500}.bak`) | ||
await fs.writeFile( | ||
pages500, | ||
` | ||
const page = () => 'custom 500 page' | ||
export const getStaticProps = () => ({ props: { a: 'b' } }) | ||
export default page | ||
` | ||
) | ||
|
||
let stderr = '' | ||
appPort = await findPort() | ||
app = await launchApp(appDir, appPort, { | ||
onStderr(msg) { | ||
stderr += msg || '' | ||
}, | ||
}) | ||
await renderViaHTTP(appPort, '/abc') | ||
await waitFor(1000) | ||
|
||
await killApp(app) | ||
|
||
await fs.remove(pages500) | ||
await fs.move(`${pages500}.bak`, pages500) | ||
|
||
expect(stderr).not.toMatch(gip500Err) | ||
}) | ||
|
||
it('shows error with getServerSideProps in pages/500 build', async () => { | ||
await fs.move(pages500, `${pages500}.bak`) | ||
await fs.writeFile( | ||
pages500, | ||
` | ||
const page = () => 'custom 500 page' | ||
export const getServerSideProps = () => ({ props: { a: 'b' } }) | ||
export default page | ||
` | ||
) | ||
await fs.remove(join(appDir, '.next')) | ||
const { stderr, code } = await nextBuild(appDir, [], { stderr: true }) | ||
await fs.remove(pages500) | ||
await fs.move(`${pages500}.bak`, pages500) | ||
|
||
expect(stderr).toMatch(gip500Err) | ||
expect(code).toBe(1) | ||
}) | ||
|
||
it('shows error with getServerSideProps in pages/500 dev', async () => { | ||
await fs.move(pages500, `${pages500}.bak`) | ||
await fs.writeFile( | ||
pages500, | ||
` | ||
const page = () => 'custom 500 page' | ||
export const getServerSideProps = () => ({ props: { a: 'b' } }) | ||
export default page | ||
` | ||
) | ||
|
||
let stderr = '' | ||
appPort = await findPort() | ||
app = await launchApp(appDir, appPort, { | ||
onStderr(msg) { | ||
stderr += msg || '' | ||
}, | ||
}) | ||
await renderViaHTTP(appPort, '/500') | ||
await waitFor(1000) | ||
|
||
await killApp(app) | ||
|
||
await fs.remove(pages500) | ||
await fs.move(`${pages500}.bak`, pages500) | ||
|
||
expect(stderr).toMatch(gip500Err) | ||
}) | ||
|
||
it('does build 500 statically with getInitialProps in _app and getStaticProps in pages/500', async () => { | ||
await fs.writeFile( | ||
pagesApp, | ||
` | ||
import App from 'next/app' | ||
const page = ({ Component, pageProps }) => <Component {...pageProps} /> | ||
page.getInitialProps = (ctx) => App.getInitialProps(ctx) | ||
export default page | ||
` | ||
) | ||
await fs.rename(pages500, `${pages500}.bak`) | ||
await fs.writeFile( | ||
pages500, | ||
` | ||
const page = () => { | ||
console.log('rendered 500') | ||
return 'custom 500 page' | ||
} | ||
export default page | ||
export const getStaticProps = () => { | ||
return { | ||
props: {} | ||
} | ||
} | ||
` | ||
) | ||
await fs.remove(join(appDir, '.next')) | ||
const { | ||
stderr, | ||
stdout: buildStdout, | ||
code, | ||
} = await nextBuild(appDir, [], { | ||
stderr: true, | ||
stdout: true, | ||
}) | ||
|
||
await fs.remove(pagesApp) | ||
await fs.remove(pages500) | ||
await fs.rename(`${pages500}.bak`, pages500) | ||
|
||
expect(stderr).not.toMatch(gip500Err) | ||
expect(buildStdout).toContain('rendered 500') | ||
expect(code).toBe(0) | ||
expect(await fs.pathExists(join(appDir, '.next/server/pages/500.html'))).toBe( | ||
true | ||
) | ||
|
||
let appStdout = '' | ||
const appPort = await findPort() | ||
const app = await nextStart(appDir, appPort, { | ||
onStdout(msg) { | ||
appStdout += msg || '' | ||
}, | ||
onStderr(msg) { | ||
appStdout += msg || '' | ||
}, | ||
}) | ||
|
||
await renderViaHTTP(appPort, '/err') | ||
await killApp(app) | ||
|
||
expect(appStdout).not.toContain('rendered 500') | ||
}) | ||
|
||
it('does not build 500 statically with no pages/500 and getServerSideProps in _error', async () => { | ||
await fs.rename(pages500, `${pages500}.bak`) | ||
await fs.writeFile( | ||
pagesError, | ||
` | ||
function Error({ statusCode }) { | ||
return <p>Error status: {statusCode}</p> | ||
} | ||
export const getServerSideProps = ({ req, res, err }) => { | ||
console.error('called _error getServerSideProps') | ||
if (req.url === '/500') { | ||
throw new Error('should not export /500') | ||
} | ||
return { | ||
props: { | ||
statusCode: res && res.statusCode ? res.statusCode : err ? err.statusCode : 404 | ||
} | ||
} | ||
} | ||
export default Error | ||
` | ||
) | ||
await fs.remove(join(appDir, '.next')) | ||
const { stderr: buildStderr, code } = await nextBuild(appDir, [], { | ||
stderr: true, | ||
}) | ||
await fs.rename(`${pages500}.bak`, pages500) | ||
await fs.remove(pagesError) | ||
console.log(buildStderr) | ||
expect(buildStderr).not.toMatch(gip500Err) | ||
expect(code).toBe(0) | ||
expect(await fs.pathExists(join(appDir, '.next/server/pages/500.html'))).toBe( | ||
false | ||
) | ||
|
||
let appStderr = '' | ||
const appPort = await findPort() | ||
const app = await nextStart(appDir, appPort, { | ||
onStderr(msg) { | ||
appStderr += msg || '' | ||
}, | ||
}) | ||
|
||
await renderViaHTTP(appPort, '/err') | ||
await killApp(app) | ||
|
||
expect(appStderr).toContain('called _error getServerSideProps') | ||
}) |
Oops, something went wrong.