Skip to content

Commit

Permalink
Turbopack build: Fix telemetry tests (#68969)
Browse files Browse the repository at this point in the history
## What?

Ensures these tests pass with Turbopack.

<!-- 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 4, 2024
1 parent 9808d72 commit 3486b2b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <h1>Hello</h1>
}
2 changes: 1 addition & 1 deletion test/integration/telemetry/pages/warning.skip
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ function a(v) {
return v
}
;['index.js'].forEach(f => {
require(a('./' + f))
require(a('./dynamic-file-imports/' + f))
})

export default () => 'Warn'
20 changes: 13 additions & 7 deletions test/integration/telemetry/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,14 @@ describe('Telemetry CLI', () => {
})

expect(stderr).toMatch(/isSrcDir.*?false/)
expect(stderr).toMatch(/package.*?"fs"/)
expect(stderr).toMatch(/package.*?"path"/)
expect(stderr).toMatch(/package.*?"http"/)
expect(stderr).toMatch(/NEXT_PACKAGE_USED_IN_GET_SERVER_SIDE_PROPS/)

// Turbopack intentionally does not support these events
if (!process.env.TURBOPACK) {
expect(stderr).toMatch(/package.*?"fs"/)
expect(stderr).toMatch(/package.*?"path"/)
expect(stderr).toMatch(/package.*?"http"/)
expect(stderr).toMatch(/NEXT_PACKAGE_USED_IN_GET_SERVER_SIDE_PROPS/)
}
await fs.move(
path.join(appDir, 'pages'),
path.join(appDir, 'src/pages')
Expand Down Expand Up @@ -170,7 +173,10 @@ describe('Telemetry CLI', () => {
path.join(appDir, 'pages', 'warning.skip')
)

expect(stderr).toMatch(/Compiled with warnings/)
// Turbopack does not have this specific log line.
if (!process.env.TURBOPACK) {
expect(stderr).toMatch(/Compiled with warnings/)
}
expect(stderr).toMatch(/NEXT_BUILD_COMPLETED/)
})

Expand Down Expand Up @@ -374,8 +380,8 @@ describe('Telemetry CLI', () => {
expect(event1).toMatch(/"staticPropsPageCount": 2/)
expect(event1).toMatch(/"serverPropsPageCount": 2/)
expect(event1).toMatch(/"ssrPageCount": 3/)
expect(event1).toMatch(/"staticPageCount": 4/)
expect(event1).toMatch(/"totalPageCount": 11/)
expect(event1).toMatch(/"staticPageCount": 5/)
expect(event1).toMatch(/"totalPageCount": 12/)
expect(event1).toMatch(/"totalAppPagesCount": 0/)
expect(event1).toMatch(/"staticAppPagesCount": 0/)
expect(event1).toMatch(/"serverAppPagesCount": 0/)
Expand Down
4 changes: 2 additions & 2 deletions test/integration/telemetry/test/page-features.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ describe('page features telemetry', () => {
expect(event1).toMatch(/"staticPropsPageCount": 2/)
expect(event1).toMatch(/"serverPropsPageCount": 2/)
expect(event1).toMatch(/"ssrPageCount": 3/)
expect(event1).toMatch(/"staticPageCount": 4/)
expect(event1).toMatch(/"totalPageCount": 11/)
expect(event1).toMatch(/"staticPageCount": 5/)
expect(event1).toMatch(/"totalPageCount": 12/)
expect(event1).toMatch(/"totalAppPagesCount": 5/)
expect(event1).toMatch(/"serverAppPagesCount": 2/)
expect(event1).toMatch(/"edgeRuntimeAppCount": 1/)
Expand Down
5 changes: 2 additions & 3 deletions test/turbopack-build-tests-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15019,12 +15019,11 @@
"Telemetry CLI production mode detect static 404 correctly for `next build`",
"Telemetry CLI production mode detects correct cli session defaults",
"Telemetry CLI production mode detects tests correctly for `next build`",
"Telemetry CLI production mode emits event when swc fails to load"
],
"failed": [
"Telemetry CLI production mode emits event when swc fails to load",
"Telemetry CLI production mode detects isSrcDir dir correctly for `next build`",
"Telemetry CLI production mode logs completed `next build` with warnings"
],
"failed": [],
"pending": [],
"flakey": [],
"runtimeError": false
Expand Down

0 comments on commit 3486b2b

Please sign in to comment.