Skip to content

Commit

Permalink
Skip production tests for Turbopack (#56089)
Browse files Browse the repository at this point in the history
Follow-up to #56045. Found there was a group of tests for production
called `server mode` instead of `production mode`, those are skipped too
now.

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

-->
  • Loading branch information
timneutkens committed Sep 27, 2023
1 parent 3eadfe9 commit cbe8238
Show file tree
Hide file tree
Showing 45 changed files with 492 additions and 484 deletions.
113 changes: 60 additions & 53 deletions test/e2e/instrumentation-hook-src/instrumentation-hook-src.test.ts
@@ -1,58 +1,65 @@
import { createNextDescribe } from 'e2e-utils'
import { check } from 'next-test-utils'

createNextDescribe(
'instrumentation-hook-src',
{
files: __dirname,
nextConfig: {
experimental: {
instrumentationHook: true,
;(process.env.TURBOPACK ? describe.skip : describe)(
'instrumentation-hook-rsc',
() => {
createNextDescribe(
'instrumentation',
{
files: __dirname,
nextConfig: {
experimental: {
instrumentationHook: true,
},
},
skipDeployment: true,
},
},
skipDeployment: true,
},
({ next, isNextDev }) => {
it('should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook/)
})
it('should not overlap with a instrumentation page', async () => {
const page = await next.render('/instrumentation')
expect(page).toContain('Hello')
})
it('should run the edge instrumentation compiled version with the edge runtime', async () => {
await next.render('/edge')
await check(() => next.cliOutput, /instrumentation hook on the edge/)
})
if (isNextDev) {
// TODO: Implement handling for changing the instrument file.
it.skip('should reload the server when the instrumentation hook changes', async () => {
await next.render('/')
await next.patchFile(
'./src/instrumentation.js',
`export function register() {console.log('toast')}`
)
await check(() => next.cliOutput, /toast/)
await next.renameFile(
'./src/instrumentation.js',
'./src/instrumentation.js.bak'
)
await check(
() => next.cliOutput,
/The instrumentation file has been removed/
)
await next.patchFile(
'./src/instrumentation.js.bak',
`export function register() {console.log('bread')}`
)
await next.renameFile(
'./src/instrumentation.js.bak',
'./src/instrumentation.js'
)
await check(() => next.cliOutput, /The instrumentation file was added/)
await check(() => next.cliOutput, /bread/)
})
}
({ next, isNextDev }) => {
it('should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook/)
})
it('should not overlap with a instrumentation page', async () => {
const page = await next.render('/instrumentation')
expect(page).toContain('Hello')
})
it('should run the edge instrumentation compiled version with the edge runtime', async () => {
await next.render('/edge')
await check(() => next.cliOutput, /instrumentation hook on the edge/)
})
if (isNextDev) {
// TODO: Implement handling for changing the instrument file.
it.skip('should reload the server when the instrumentation hook changes', async () => {
await next.render('/')
await next.patchFile(
'./src/instrumentation.js',
`export function register() {console.log('toast')}`
)
await check(() => next.cliOutput, /toast/)
await next.renameFile(
'./src/instrumentation.js',
'./src/instrumentation.js.bak'
)
await check(
() => next.cliOutput,
/The instrumentation file has been removed/
)
await next.patchFile(
'./src/instrumentation.js.bak',
`export function register() {console.log('bread')}`
)
await next.renameFile(
'./src/instrumentation.js.bak',
'./src/instrumentation.js'
)
await check(
() => next.cliOutput,
/The instrumentation file was added/
)
await check(() => next.cliOutput, /bread/)
})
}
}
)
}
)
202 changes: 104 additions & 98 deletions test/e2e/instrumentation-hook/instrumentation-hook.test.ts
Expand Up @@ -20,117 +20,123 @@ const describeCase = (
callback
)
}
describe('Instrumentation Hook', () => {
// TODO: investigate the failure with esm import
// createNextDescribe(
// 'with-esm-import',
// {
// files: path.join(__dirname, 'with-esm-import'),
// nextConfig: {
// experimental: {
// instrumentationHook: true,
// },
// },
// dependencies: {
// // This test is mostly for compatibility with this package
// '@vercel/otel': 'latest',
// },
// skipDeployment: true,
// },
// ({ next }) => {
// eslint-disable-next-line jest/no-commented-out-tests
// it('with-esm-import should run the instrumentation hook', async () => {
// await next.render('/')
// await check(
// () => next.cliOutput,
// /register in instrumentation\.js is running/
// )
// })
// }
// )
;(process.env.TURBOPACK ? describe.skip : describe)(
'Instrumentation Hook',
() => {
// TODO: investigate the failure with esm import
// createNextDescribe(
// 'with-esm-import',
// {
// files: path.join(__dirname, 'with-esm-import'),
// nextConfig: {
// experimental: {
// instrumentationHook: true,
// },
// },
// dependencies: {
// // This test is mostly for compatibility with this package
// '@vercel/otel': 'latest',
// },
// skipDeployment: true,
// },
// ({ next }) => {
// eslint-disable-next-line jest/no-commented-out-tests
// it('with-esm-import should run the instrumentation hook', async () => {
// await next.render('/')
// await check(
// () => next.cliOutput,
// /register in instrumentation\.js is running/
// )
// })
// }
// )

describeCase('with-middleware', ({ next }) => {
it('with-middleware should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook on the edge/)
describeCase('with-middleware', ({ next }) => {
it('with-middleware should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook on the edge/)
})
})
})

describeCase('with-edge-api', ({ next }) => {
it('with-edge-api should run the instrumentation hook', async () => {
await next.render('/api')
await check(() => next.cliOutput, /instrumentation hook on the edge/)
describeCase('with-edge-api', ({ next }) => {
it('with-edge-api should run the instrumentation hook', async () => {
await next.render('/api')
await check(() => next.cliOutput, /instrumentation hook on the edge/)
})
})
})

describeCase('with-edge-page', ({ next }) => {
it('with-edge-page should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook on the edge/)
describeCase('with-edge-page', ({ next }) => {
it('with-edge-page should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook on the edge/)
})
})
})

describeCase('with-node-api', ({ next }) => {
it('with-node-api should run the instrumentation hook', async () => {
await next.render('/api')
await check(() => next.cliOutput, /instrumentation hook on nodejs/)
describeCase('with-node-api', ({ next }) => {
it('with-node-api should run the instrumentation hook', async () => {
await next.render('/api')
await check(() => next.cliOutput, /instrumentation hook on nodejs/)
})
})
})

describeCase('with-node-page', ({ next }) => {
it('with-node-page should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook on nodejs/)
describeCase('with-node-page', ({ next }) => {
it('with-node-page should run the instrumentation hook', async () => {
await next.render('/')
await check(() => next.cliOutput, /instrumentation hook on nodejs/)
})
})
})

describeCase('with-async-node-page', ({ next }) => {
it('with-async-node-page should run the instrumentation hook', async () => {
const page = await next.render('/')
expect(page).toContain('Node - finished: true')
describeCase('with-async-node-page', ({ next }) => {
it('with-async-node-page should run the instrumentation hook', async () => {
const page = await next.render('/')
expect(page).toContain('Node - finished: true')
})
})
})

describeCase('with-async-edge-page', ({ next }) => {
it('with-async-edge-page should run the instrumentation hook', async () => {
const page = await next.render('/')
expect(page).toContain('Edge - finished: true')
describeCase('with-async-edge-page', ({ next }) => {
it('with-async-edge-page should run the instrumentation hook', async () => {
const page = await next.render('/')
expect(page).toContain('Edge - finished: true')
})
})
})

describeCase('general', ({ next, isNextDev }) => {
it('should not overlap with a instrumentation page', async () => {
const page = await next.render('/instrumentation')
expect(page).toContain('Hello')
})
if (isNextDev) {
// TODO: Implement handling for changing the instrument file.
it.skip('should reload the server when the instrumentation hook changes', async () => {
await next.render('/')
await next.patchFile(
'./instrumentation.js',
`export function register() {console.log('toast')}`
)
await check(() => next.cliOutput, /toast/)
await next.renameFile(
'./instrumentation.js',
'./instrumentation.js.bak'
)
await check(
() => next.cliOutput,
/The instrumentation file has been removed/
)
await next.patchFile(
'./instrumentation.js.bak',
`export function register() {console.log('bread')}`
)
await next.renameFile(
'./instrumentation.js.bak',
'./instrumentation.js'
)
await check(() => next.cliOutput, /The instrumentation file was added/)
await check(() => next.cliOutput, /bread/)
describeCase('general', ({ next, isNextDev }) => {
it('should not overlap with a instrumentation page', async () => {
const page = await next.render('/instrumentation')
expect(page).toContain('Hello')
})
}
})
})
if (isNextDev) {
// TODO: Implement handling for changing the instrument file.
it.skip('should reload the server when the instrumentation hook changes', async () => {
await next.render('/')
await next.patchFile(
'./instrumentation.js',
`export function register() {console.log('toast')}`
)
await check(() => next.cliOutput, /toast/)
await next.renameFile(
'./instrumentation.js',
'./instrumentation.js.bak'
)
await check(
() => next.cliOutput,
/The instrumentation file has been removed/
)
await next.patchFile(
'./instrumentation.js.bak',
`export function register() {console.log('bread')}`
)
await next.renameFile(
'./instrumentation.js.bak',
'./instrumentation.js'
)
await check(
() => next.cliOutput,
/The instrumentation file was added/
)
await check(() => next.cliOutput, /bread/)
})
}
})
}
)
2 changes: 1 addition & 1 deletion test/integration/404-page-custom-error/test/index.test.js
Expand Up @@ -51,7 +51,7 @@ const runTests = (mode) => {
}

describe('Default 404 Page with custom _error', () => {
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterAll(() => killApp(app))

it('should build successfully', async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/404-page-ssg/test/index.test.js
Expand Up @@ -76,7 +76,7 @@ const runTests = (isDev) => {
}

describe('404 Page Support SSG', () => {
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
afterAll(() => killApp(app))

it('should build successfully', async () => {
Expand Down
3 changes: 1 addition & 2 deletions test/integration/404-page/test/index.test.js
Expand Up @@ -79,8 +79,7 @@ describe('404 Page Support', () => {

runTests('dev')
})

describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
Expand Down
3 changes: 1 addition & 2 deletions test/integration/500-page/test/index.test.js
Expand Up @@ -70,8 +70,7 @@ describe('500 Page Support', () => {

runTests('dev')
})

describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await fs.remove(join(appDir, '.next'))
await nextBuild(appDir)
Expand Down
2 changes: 1 addition & 1 deletion test/integration/amphtml-ssg/test/index.test.js
Expand Up @@ -98,7 +98,7 @@ const runTests = (isDev = false) => {
}

describe('AMP SSG Support', () => {
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
Expand Down
2 changes: 1 addition & 1 deletion test/integration/auto-export-error-bail/test/index.test.js
Expand Up @@ -30,7 +30,7 @@ const runTests = () => {
}

describe('Auto Export _error bail', () => {
describe('server mode', () => {
;(process.env.TURBOPACK ? describe.skip : describe)('production mode', () => {
runTests()
})
})

0 comments on commit cbe8238

Please sign in to comment.