Skip to content

Commit

Permalink
Turbopack test updates (vercel#60662)
Browse files Browse the repository at this point in the history
## What?

Updates snapshots for Turbopack tests. They're slightly different than
the webpack output. Generally better because column information is
preserved. The import trace is not available in Turbopack as it would
make the parent module a direct dependency of the module, meaning it
would have to recompile every time you can the parent module. We'll
figure out if it can be added in a different way at a later point.

<!-- 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-2101
  • Loading branch information
timneutkens committed Jan 15, 2024
1 parent e169e73 commit fe73226
Show file tree
Hide file tree
Showing 5 changed files with 309 additions and 212 deletions.
104 changes: 65 additions & 39 deletions test/development/acceptance-app/ReactRefreshLogBox-builtins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,28 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
`
)
expect(await session.hasRedbox()).toBe(true)
expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"./node_modules/my-package/index.js:1:12
Module not found: Can't resolve 'dns'
if (process.env.TURBOPACK) {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"./node_modules/my-package/index.js:1:12
Module not found: Can't resolve 'dns'
> 1 | const dns = require('dns')
| ^^^^^^^^^^^^^^
2 | module.exports = dns
https://nextjs.org/docs/messages/module-not-found"
`)
} else {
expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
"./node_modules/my-package/index.js:1:12
Module not found: Can't resolve 'dns'
https://nextjs.org/docs/messages/module-not-found
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./index.js
./app/page.js"
`)
Import trace for requested module:
./index.js
./app/page.js"
`)
}

await cleanup()
})
Expand All @@ -84,19 +96,33 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
expect(await session.hasRedbox()).toBe(true)

const source = await session.getRedboxSource()
expect(source).toMatchInlineSnapshot(`
"./index.js:1:0
Module not found: Can't resolve 'b'
> 1 | import Comp from 'b'
2 | export default function Oops() {
3 | return (
4 | <div>
if (process.env.TURBOPACK) {
expect(source).toMatchInlineSnapshot(`
"./index.js:1:0
Module not found: Can't resolve 'b'
> 1 | import Comp from 'b'
| ^^^^^^^^^^^^^^^^^^^^
2 | export default function Oops() {
3 | return (
4 | <div>
https://nextjs.org/docs/messages/module-not-found"
`)
} else {
expect(source).toMatchInlineSnapshot(`
"./index.js:1:0
Module not found: Can't resolve 'b'
> 1 | import Comp from 'b'
2 | export default function Oops() {
3 | return (
4 | <div>
https://nextjs.org/docs/messages/module-not-found
https://nextjs.org/docs/messages/module-not-found
Import trace for requested module:
./app/page.js"
`)
Import trace for requested module:
./app/page.js"
`)
}

await cleanup()
})
Expand Down Expand Up @@ -137,16 +163,16 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
`)
} else {
expect(source).toMatchInlineSnapshot(`
"./app/page.js:2:0
Module not found: Can't resolve 'b'
1 | 'use client'
> 2 | import Comp from 'b'
3 | export default function Oops() {
4 | return (
5 | <div>
https://nextjs.org/docs/messages/module-not-found"
`)
"./app/page.js:2:0
Module not found: Can't resolve 'b'
1 | 'use client'
> 2 | import Comp from 'b'
3 | export default function Oops() {
4 | return (
5 | <div>
https://nextjs.org/docs/messages/module-not-found"
`)
}

await cleanup()
Expand Down Expand Up @@ -186,16 +212,16 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
`)
} else {
expect(source).toMatchInlineSnapshot(`
"./app/page.js:2:0
Module not found: Can't resolve './non-existent.css'
1 | 'use client'
> 2 | import './non-existent.css'
3 | export default function Page(props) {
4 | return <p>index page</p>
5 | }
https://nextjs.org/docs/messages/module-not-found"
`)
"./app/page.js:2:0
Module not found: Can't resolve './non-existent.css'
1 | 'use client'
> 2 | import './non-existent.css'
3 | export default function Page(props) {
4 | return <p>index page</p>
5 | }
https://nextjs.org/docs/messages/module-not-found"
`)
}
await session.patch(
'app/page.js',
Expand Down

0 comments on commit fe73226

Please sign in to comment.