Skip to content

Commit

Permalink
Skip test/integration development tests during Turbopack build test r…
Browse files Browse the repository at this point in the history
…un (#63671)

## What?

Follow-up to #63665.

Ensures development tests are skipped during the production build run
for Turbopack (i.e. used to create the turbopack-build-tests-manifest).

Adds `pnpm test-dev-turbo` and `pnpm test-start-turbo` (and their
`testonly` equivalent) for running tests.

<!-- 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 #

-->


Closes NEXT-2915
  • Loading branch information
timneutkens committed Mar 25, 2024
1 parent 9677c87 commit 69f5fb2
Show file tree
Hide file tree
Showing 137 changed files with 2,816 additions and 2,387 deletions.
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
"test-types": "tsc",
"test-unit": "jest test/unit/ packages/next/ packages/font",
"test-dev": "cross-env NEXT_TEST_MODE=dev pnpm testheadless",
"test-dev-turbo": "cross-env NEXT_TEST_MODE=dev TURBOPACK=1 TURBOPACK_DEV=1 pnpm testheadless",
"test-start": "cross-env NEXT_TEST_MODE=start pnpm testheadless",
"test-start-turbo": "cross-env NEXT_TEST_MODE=start TURBOPACK=1 TURBOPACK_BUILD=1 pnpm testheadless",
"test-deploy": "cross-env NEXT_TEST_MODE=deploy pnpm testheadless",
"testonly-dev": "cross-env NEXT_TEST_MODE=dev pnpm testonly",
"testonly-dev-turbo": "cross-env NEXT_TEST_MODE=dev TURBOPACK=1 TURBOPACK_DEV=1 pnpm testonly",
"testonly-start": "cross-env NEXT_TEST_MODE=start pnpm testonly",
"testonly-start-turbo": "cross-env NEXT_TEST_MODE=start TURBOPACK=1 TURBOPACK_BUILD=1 pnpm testonly",
"testonly-deploy": "cross-env NEXT_TEST_MODE=deploy pnpm testonly",
"test": "pnpm testheadless",
"testonly": "jest --runInBand",
Expand Down
50 changes: 26 additions & 24 deletions test/integration/404-page-app/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,31 +61,33 @@ describe('404 Page Support with _app', () => {
})
}
)
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode',
() => {
let stderr = ''
let stdout = ''

describe('development mode', () => {
let stderr = ''
let stdout = ''

beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStderr(msg) {
stderr += msg
},
onStdout(msg) {
stdout += msg
},
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStderr(msg) {
stderr += msg
},
onStdout(msg) {
stdout += msg
},
})
})
})
afterAll(() => killApp(app))
afterAll(() => killApp(app))

it('should not show pages/404 GIP error if _app has GIP', async () => {
const res = await fetchViaHTTP(appPort, '/abc')
expect(res.status).toBe(404)
const $ = cheerio.load(await res.text())
expect($('#404-title').text()).toBe('Hi There')
expect(stderr).not.toMatch(gip404Err)
expect(stdout).not.toMatch(gip404Err)
})
})
it('should not show pages/404 GIP error if _app has GIP', async () => {
const res = await fetchViaHTTP(appPort, '/abc')
expect(res.status).toBe(404)
const $ = cheerio.load(await res.text())
expect($('#404-title').text()).toBe('Hi There')
expect(stderr).not.toMatch(gip404Err)
expect(stdout).not.toMatch(gip404Err)
})
}
)
})
20 changes: 11 additions & 9 deletions test/integration/404-page-custom-error/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,16 @@ describe('Default 404 Page with custom _error', () => {
runTests('server')
}
)
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode',
() => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => killApp(app))

describe('development mode', () => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => killApp(app))

runTests('dev')
})
runTests('dev')
}
)
})
36 changes: 19 additions & 17 deletions test/integration/404-page-ssg/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,25 @@ describe('404 Page Support SSG', () => {
runTests()
}
)

describe('development mode', () => {
beforeAll(async () => {
appPort = await findPort()
stderr = ''
stdout = ''
app = await launchApp(appDir, appPort, {
onStdout(msg) {
stdout += msg
},
onStderr(msg) {
stderr += msg
},
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode',
() => {
beforeAll(async () => {
appPort = await findPort()
stderr = ''
stdout = ''
app = await launchApp(appDir, appPort, {
onStdout(msg) {
stdout += msg
},
onStderr(msg) {
stderr += msg
},
})
})
})
afterAll(() => killApp(app))
afterAll(() => killApp(app))

runTests(true)
})
runTests(true)
}
)
})
19 changes: 11 additions & 8 deletions test/integration/404-page/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,18 @@ const runTests = (mode = 'server') => {
}

describe('404 Page Support', () => {
describe('development mode', () => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => killApp(app))
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode',
() => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => killApp(app))

runTests('dev')
})
runTests('dev')
}
)
describe('development mode 2', () => {
it('falls back to _error correctly without pages/404', async () => {
await fs.move(pages404, `${pages404}.bak`)
Expand Down
92 changes: 47 additions & 45 deletions test/integration/500-page/test/gsp-gssp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,64 +183,66 @@ describe('gsp-gssp', () => {
})
}
)

describe('development mode', () => {
it('does not show error with getStaticProps in pages/500 dev', async () => {
await fs.move(pages500, `${pages500}.bak`)
await fs.writeFile(
pages500,
`
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode',
() => {
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)
let stderr = ''
appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStderr(msg) {
stderr += msg || ''
},
})
await renderViaHTTP(appPort, '/abc')
await waitFor(1000)

await fs.remove(pages500)
await fs.move(`${pages500}.bak`, pages500)
await killApp(app)

expect(stderr).not.toMatch(gip500Err)
})
await fs.remove(pages500)
await fs.move(`${pages500}.bak`, pages500)

it('shows error with getServerSideProps in pages/500 dev', async () => {
await fs.move(pages500, `${pages500}.bak`)
await fs.writeFile(
pages500,
`
expect(stderr).not.toMatch(gip500Err)
})

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)
)

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 killApp(app)

await fs.remove(pages500)
await fs.move(`${pages500}.bak`, pages500)
await fs.remove(pages500)
await fs.move(`${pages500}.bak`, pages500)

expect(stderr).toMatch(gip500Err)
})
})
expect(stderr).toMatch(gip500Err)
})
}
)
})
21 changes: 12 additions & 9 deletions test/integration/500-page/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,19 @@ const runTests = (mode = 'server') => {
}

describe('500 Page Support', () => {
describe('development mode', () => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => killApp(app))
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode',
() => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => killApp(app))

runTests('dev')
})
runTests('dev')
}
)
describe('development mode 2', () => {
it('shows error with getInitialProps in pages/500 dev', async () => {
await fs.move(pages500, `${pages500}.bak`)
Expand Down
34 changes: 18 additions & 16 deletions test/integration/amphtml-custom-validator/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,26 @@ const appDir = join(__dirname, '../')
})
}
)
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode',
() => {
it('should run in development mode successfully', async () => {
let stderr = ''

describe('development mode', () => {
it('should run in development mode successfully', async () => {
let stderr = ''

appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStderr(msg) {
stderr += msg || ''
},
})
appPort = await findPort()
app = await launchApp(appDir, appPort, {
onStderr(msg) {
stderr += msg || ''
},
})

const html = await renderViaHTTP(appPort, '/')
await killApp(app)
const html = await renderViaHTTP(appPort, '/')
await killApp(app)

expect(stderr).not.toContain('error')
expect(html).toContain('Hello from AMP')
})
})
expect(stderr).not.toContain('error')
expect(html).toContain('Hello from AMP')
})
}
)
}
)
19 changes: 11 additions & 8 deletions test/integration/amphtml-ssg/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,17 @@ describe('AMP SSG Support', () => {
runTests()
}
)
describe('development mode', () => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => killApp(app))
runTests(true)
})
;(process.env.TURBOPACK_BUILD ? describe.skip : describe)(
'development mode',
() => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => killApp(app))
runTests(true)
}
)
describe('export mode', () => {
;(process.env.TURBOPACK_DEV ? describe.skip : describe)(
'production mode',
Expand Down
Loading

0 comments on commit 69f5fb2

Please sign in to comment.