Skip to content

Commit 70c087e

Browse files
authored
Fix flaky invalid import test (#46089)
<!-- 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: --> ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
1 parent 0bc4d56 commit 70c087e

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

test/development/acceptance-app/invalid-imports.test.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ createNextDescribe(
188188
[
189189
'app/comp2.js',
190190
`
191-
import "server-only-package"
192191
export function Comp2() {
193192
return (
194193
<div>Hello world</div>
@@ -210,9 +209,9 @@ createNextDescribe(
210209
])
211210
)
212211

213-
const pageFile = 'app/page.js'
214-
const content = await next.readFile(pageFile)
215-
await session.patch(pageFile, '"use client"\n' + content)
212+
const file = 'app/comp2.js'
213+
const content = await next.readFile(file)
214+
await session.patch(file, 'import "server-only-package"\n' + content)
216215

217216
expect(await session.hasRedbox(true)).toBe(true)
218217
expect(await session.getRedboxSource()).toMatchInlineSnapshot(`
@@ -222,9 +221,9 @@ createNextDescribe(
222221
The error was caused by importing 'server-only-package/index.js' in 'app/comp2.js'.
223222
224223
Import trace for requested module:
225-
app/comp2.js
226-
app/comp1.js
227-
app/page.js"
224+
app/comp2.js
225+
app/comp1.js
226+
app/page.js"
228227
`)
229228

230229
await cleanup()

0 commit comments

Comments
 (0)