Skip to content

Commit 55330fe

Browse files
committed
Update tests to new error strings
1 parent 0024317 commit 55330fe

16 files changed

+447
-589
lines changed

test/development/app-dir/async-request-warnings/async-request-warnings.test.ts

Lines changed: 45 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,20 @@ describe('dynamic-requests warnings', () => {
1616
.map((log) => log.message)
1717
const terminalOutput = next.cliOutput.slice(nextDevBootstrapOutputIndex)
1818
const terminalCookieErrors = terminalOutput.split('\n').filter((line) => {
19-
return line.includes('In route /request/cookies')
19+
return line.includes('Route "/request/cookies')
2020
})
2121
expect({ browserConsoleErrors, terminalCookieErrors }).toEqual({
2222
browserConsoleErrors: [
23-
expect.stringContaining(
24-
"In route /request/cookies a cookie property was accessed directly with `cookies().get('page')`."
25-
),
26-
expect.stringContaining(
27-
"In route /request/cookies a cookie property was accessed directly with `cookies().get('component')`."
28-
),
29-
expect.stringContaining(
30-
"In route /request/cookies a cookie property was accessed directly with `cookies().has('component')`."
31-
),
32-
expect.stringContaining(
33-
'In route /request/cookies cookies were iterated over'
34-
),
23+
expect.stringContaining("`cookies().get('page')`."),
24+
expect.stringContaining("`cookies().get('component')`."),
25+
expect.stringContaining("`cookies().has('component')`."),
26+
expect.stringContaining('`...cookies()` or similar iteration'),
3527
],
3628
terminalCookieErrors: [
37-
expect.stringContaining(
38-
"In route /request/cookies a cookie property was accessed directly with `cookies().get('page')`."
39-
),
40-
expect.stringContaining(
41-
"In route /request/cookies a cookie property was accessed directly with `cookies().get('component')`."
42-
),
43-
expect.stringContaining(
44-
"In route /request/cookies a cookie property was accessed directly with `cookies().has('component')`."
45-
),
46-
expect.stringContaining(
47-
'In route /request/cookies cookies were iterated over'
48-
),
29+
expect.stringContaining("`cookies().get('page')`."),
30+
expect.stringContaining("`cookies().get('component')`."),
31+
expect.stringContaining("`cookies().has('component')`."),
32+
expect.stringContaining('`...cookies()` or similar iteration'),
4933
],
5034
})
5135
})
@@ -61,36 +45,20 @@ describe('dynamic-requests warnings', () => {
6145
.map((log) => log.message)
6246
const terminalOutput = next.cliOutput.slice(nextDevBootstrapOutputIndex)
6347
const terminalCookieErrors = terminalOutput.split('\n').filter((line) => {
64-
return line.includes('In route /request/draftMode')
48+
return line.includes('Route "/request/draftMode')
6549
})
6650
expect({ browserConsoleErrors, terminalCookieErrors }).toEqual({
6751
browserConsoleErrors: [
68-
expect.stringContaining(
69-
'In route /request/draftMode a `draftMode()` property was accessed directly with `draftMode().isEnabled`.'
70-
),
71-
expect.stringContaining(
72-
'In route /request/draftMode a `draftMode()` property was accessed directly with `draftMode().isEnabled`.'
73-
),
74-
expect.stringContaining(
75-
'In route /request/draftMode a `draftMode()` property was accessed directly with `draftMode().enable()`.'
76-
),
77-
expect.stringContaining(
78-
'In route /request/draftMode a `draftMode()` property was accessed directly with `draftMode().isEnabled`.'
79-
),
52+
expect.stringContaining('`draftMode().isEnabled`.'),
53+
expect.stringContaining('`draftMode().isEnabled`.'),
54+
expect.stringContaining('`draftMode().enable()`.'),
55+
expect.stringContaining('`draftMode().isEnabled`.'),
8056
],
8157
terminalCookieErrors: [
82-
expect.stringContaining(
83-
'In route /request/draftMode a `draftMode()` property was accessed directly with `draftMode().isEnabled`.'
84-
),
85-
expect.stringContaining(
86-
'In route /request/draftMode a `draftMode()` property was accessed directly with `draftMode().isEnabled`.'
87-
),
88-
expect.stringContaining(
89-
'In route /request/draftMode a `draftMode()` property was accessed directly with `draftMode().enable()`.'
90-
),
91-
expect.stringContaining(
92-
'In route /request/draftMode a `draftMode()` property was accessed directly with `draftMode().isEnabled`.'
93-
),
58+
expect.stringContaining('`draftMode().isEnabled`.'),
59+
expect.stringContaining('`draftMode().isEnabled`.'),
60+
expect.stringContaining('`draftMode().enable()`.'),
61+
expect.stringContaining('`draftMode().isEnabled`.'),
9462
],
9563
})
9664
})
@@ -106,36 +74,20 @@ describe('dynamic-requests warnings', () => {
10674
.map((log) => log.message)
10775
const terminalOutput = next.cliOutput.slice(nextDevBootstrapOutputIndex)
10876
const terminalCookieErrors = terminalOutput.split('\n').filter((line) => {
109-
return line.includes('In route /request/headers')
77+
return line.includes('Route "/request/headers')
11078
})
11179
expect({ browserConsoleErrors, terminalCookieErrors }).toEqual({
11280
browserConsoleErrors: [
113-
expect.stringContaining(
114-
"In route /request/headers a header property was accessed directly with `headers().get('page')`."
115-
),
116-
expect.stringContaining(
117-
"In route /request/headers a header property was accessed directly with `headers().get('component')`."
118-
),
119-
expect.stringContaining(
120-
"In route /request/headers a header property was accessed directly with `headers().has('component')`."
121-
),
122-
expect.stringContaining(
123-
'In route /request/headers headers were iterated over'
124-
),
81+
expect.stringContaining("`headers().get('page')`."),
82+
expect.stringContaining("`headers().get('component')`."),
83+
expect.stringContaining("`headers().has('component')`."),
84+
expect.stringContaining('`...headers()` or similar iteration'),
12585
],
12686
terminalCookieErrors: [
127-
expect.stringContaining(
128-
"In route /request/headers a header property was accessed directly with `headers().get('page')`."
129-
),
130-
expect.stringContaining(
131-
"In route /request/headers a header property was accessed directly with `headers().get('component')`."
132-
),
133-
expect.stringContaining(
134-
"In route /request/headers a header property was accessed directly with `headers().has('component')`."
135-
),
136-
expect.stringContaining(
137-
'In route /request/headers headers were iterated over'
138-
),
87+
expect.stringContaining("`headers().get('page')`."),
88+
expect.stringContaining("`headers().get('component')`."),
89+
expect.stringContaining("`headers().has('component')`."),
90+
expect.stringContaining('`...headers()` or similar iteration'),
13991
],
14092
})
14193
})
@@ -151,36 +103,20 @@ describe('dynamic-requests warnings', () => {
151103
.map((log) => log.message)
152104
const terminalOutput = next.cliOutput.slice(nextDevBootstrapOutputIndex)
153105
const terminalCookieErrors = terminalOutput.split('\n').filter((line) => {
154-
return line.includes('In route /request/params/[slug]')
106+
return line.includes('Route "/request/params/[slug]')
155107
})
156108
expect({ browserConsoleErrors, terminalCookieErrors }).toEqual({
157109
browserConsoleErrors: [
158-
expect.stringContaining(
159-
'In route /request/params/[slug] a param property was accessed directly with `params.slug`.'
160-
),
161-
expect.stringContaining(
162-
'In route /request/params/[slug] a param property was accessed directly with `params.slug`.'
163-
),
164-
expect.stringContaining(
165-
'In route /request/params/[slug] a param property was accessed directly with `params.slug`.'
166-
),
167-
expect.stringContaining(
168-
'In route /request/params/[slug] params are being enumerated'
169-
),
110+
expect.stringContaining('`params.slug`.'),
111+
expect.stringContaining('`params.slug`.'),
112+
expect.stringContaining('`params.slug`.'),
113+
expect.stringContaining('`...params` or similar expression'),
170114
],
171115
terminalCookieErrors: [
172-
expect.stringContaining(
173-
'In route /request/params/[slug] a param property was accessed directly with `params.slug`.'
174-
),
175-
expect.stringContaining(
176-
'In route /request/params/[slug] a param property was accessed directly with `params.slug`.'
177-
),
178-
expect.stringContaining(
179-
'In route /request/params/[slug] a param property was accessed directly with `params.slug`.'
180-
),
181-
expect.stringContaining(
182-
'In route /request/params/[slug] params are being enumerated'
183-
),
116+
expect.stringContaining('`params.slug`.'),
117+
expect.stringContaining('`params.slug`.'),
118+
expect.stringContaining('`params.slug`.'),
119+
expect.stringContaining('`...params` or similar expression'),
184120
],
185121
})
186122
})
@@ -196,36 +132,20 @@ describe('dynamic-requests warnings', () => {
196132
.map((log) => log.message)
197133
const terminalOutput = next.cliOutput.slice(nextDevBootstrapOutputIndex)
198134
const terminalCookieErrors = terminalOutput.split('\n').filter((line) => {
199-
return line.includes('In route /request/searchParams')
135+
return line.includes('Route "/request/searchParams')
200136
})
201137
expect({ browserConsoleErrors, terminalCookieErrors }).toEqual({
202138
browserConsoleErrors: [
203-
expect.stringContaining(
204-
'In route /request/searchParams a searchParam property was accessed directly with `searchParams.slug`.'
205-
),
206-
expect.stringContaining(
207-
'In route /request/searchParams a searchParam property was accessed directly with `searchParams.slug`.'
208-
),
209-
expect.stringContaining(
210-
'In route /request/searchParams a searchParam property was accessed directly with `searchParams.slug`.'
211-
),
212-
expect.stringContaining(
213-
'In route /request/searchParams searchParams are being enumerated'
214-
),
139+
expect.stringContaining('`searchParams.slug`.'),
140+
expect.stringContaining('`searchParams.slug`.'),
141+
expect.stringContaining('`searchParams.slug`.'),
142+
expect.stringContaining('`Object.keys(searchParams)` or similar'),
215143
],
216144
terminalCookieErrors: [
217-
expect.stringContaining(
218-
'In route /request/searchParams a searchParam property was accessed directly with `searchParams.slug`.'
219-
),
220-
expect.stringContaining(
221-
'In route /request/searchParams a searchParam property was accessed directly with `searchParams.slug`.'
222-
),
223-
expect.stringContaining(
224-
'In route /request/searchParams a searchParam property was accessed directly with `searchParams.slug`.'
225-
),
226-
expect.stringContaining(
227-
'In route /request/searchParams searchParams are being enumerated'
228-
),
145+
expect.stringContaining('`searchParams.slug`.'),
146+
expect.stringContaining('`searchParams.slug`.'),
147+
expect.stringContaining('`searchParams.slug`.'),
148+
expect.stringContaining('`Object.keys(searchParams)` or similar'),
229149
],
230150
})
231151
})

test/e2e/app-dir/dynamic-data/dynamic-data.test.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,14 @@ describe('dynamic-data', () => {
2828
// in dev we expect the entire page to be rendered at runtime
2929
expect($('#layout').text()).toBe('at runtime')
3030
expect($('#page').text()).toBe('at runtime')
31-
// we expect there to be no suspense boundary in fallback state
32-
expect($('#boundary').html()).toBeNull()
3331
} else if (process.env.__NEXT_EXPERIMENTAL_PPR) {
3432
// in PPR we expect the shell to be rendered at build and the page to be rendered at runtime
3533
expect($('#layout').text()).toBe('at buildtime')
3634
expect($('#page').text()).toBe('at runtime')
37-
// we expect there to be a suspense boundary in fallback state
38-
expect($('#boundary').html()).not.toBeNull()
3935
} else {
4036
// in static generation we expect the entire page to be rendered at runtime
4137
expect($('#layout').text()).toBe('at runtime')
4238
expect($('#page').text()).toBe('at runtime')
43-
// we expect there to be no suspense boundary in fallback state
44-
expect($('#boundary').html()).toBeNull()
4539
}
4640

4741
expect($('#headers .fooheader').text()).toBe('foo header value')
@@ -64,21 +58,15 @@ describe('dynamic-data', () => {
6458
// in dev we expect the entire page to be rendered at runtime
6559
expect($('#layout').text()).toBe('at runtime')
6660
expect($('#page').text()).toBe('at runtime')
67-
// we expect there to be no suspense boundary in fallback state
68-
expect($('#boundary').html()).toBeNull()
6961
} else if (process.env.__NEXT_EXPERIMENTAL_PPR) {
7062
// @TODO this should actually be build but there is a bug in how we do segment level dynamic in PPR at the moment
7163
// see note in create-component-tree
7264
expect($('#layout').text()).toBe('at runtime')
7365
expect($('#page').text()).toBe('at runtime')
74-
// we expect there to be a suspense boundary in fallback state
75-
expect($('#boundary').html()).toBeNull()
7666
} else {
7767
// in static generation we expect the entire page to be rendered at runtime
7868
expect($('#layout').text()).toBe('at runtime')
7969
expect($('#page').text()).toBe('at runtime')
80-
// we expect there to be no suspense boundary in fallback state
81-
expect($('#boundary').html()).toBeNull()
8270
}
8371

8472
expect($('#headers .fooheader').text()).toBe('foo header value')

test/e2e/app-dir/dynamic-io-errors/dynamic-io-errors.platform-dynamic.test.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ function createExpectError(cliOutput: string) {
3939
}
4040

4141
function runTests(options: { withMinification: boolean }) {
42-
const isTurbopack = !!process.env.TURBOPACK
4342
const { withMinification } = options
4443
describe(`Dynamic IO Errors - ${withMinification ? 'With Minification' : 'Without Minification'}`, () => {
4544
describe('Sync Dynamic - With Fallback - Math.random()', () => {
@@ -126,11 +125,6 @@ function runTests(options: { withMinification: boolean }) {
126125
expectError(
127126
'Error: Route "/" used `Math.random()` outside of `"use cache"` and without explicitly calling `await connection()` beforehand. See more info here: https://nextjs.org/docs/messages/next-prerender-random'
128127
)
129-
expectError(
130-
'Error: In Route "/" this parent component stack may help you locate where `Math.random()` was used.',
131-
// Turbopack doesn't support disabling minification yet
132-
withMinification || isTurbopack ? undefined : 'IndirectionTwo'
133-
)
134128
expectError('Error occurred prerendering page "/"')
135129
expectError('Error: Route "/" could not be prerendered.')
136130
expectError('exiting the build.')

test/e2e/app-dir/dynamic-io-errors/dynamic-io-errors.sync-dynamic.test.ts

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ function createExpectError(cliOutput: string) {
3939
}
4040

4141
function runTests(options: { withMinification: boolean }) {
42-
const isTurbopack = !!process.env.TURBOPACK
4342
const { withMinification } = options
4443
describe(`Dynamic IO Errors - ${withMinification ? 'With Minification' : 'Without Minification'}`, () => {
4544
describe('Sync Dynamic - With Fallback - client searchParams', () => {
@@ -123,14 +122,7 @@ function runTests(options: { withMinification: boolean }) {
123122
}
124123
const expectError = createExpectError(next.cliOutput)
125124

126-
expectError(
127-
'Error: Route "/" used `searchParams.foo`. `searchParams` is now a Promise and should be `awaited` before accessing search param values. See more info here: https://nextjs.org/docs/messages/next-prerender-sync-params'
128-
)
129-
expectError(
130-
'Error: In Route "/" this parent component stack may help you locate where `searchParams.foo` was used.',
131-
// Turbopack doesn't support disabling minification yet
132-
withMinification || isTurbopack ? undefined : 'IndirectionTwo'
133-
)
125+
expectError('Route "/" used `searchParams.foo`')
134126
expectError('Error occurred prerendering page "/"')
135127
expectError('Error: Route "/" could not be prerendered.')
136128
expectError('exiting the build.')
@@ -218,14 +210,7 @@ function runTests(options: { withMinification: boolean }) {
218210
}
219211
const expectError = createExpectError(next.cliOutput)
220212

221-
expectError(
222-
'Error: Route "/" used `searchParams.foo`. `searchParams` is now a Promise and should be `awaited` before accessing search param values. See more info here: https://nextjs.org/docs/messages/next-prerender-sync-params'
223-
)
224-
expectError(
225-
'Error: In Route "/" this parent component stack may help you locate where `searchParams.foo` was used.',
226-
// Turbopack doesn't support disabling minification yet
227-
withMinification || isTurbopack ? undefined : 'IndirectionTwo'
228-
)
213+
expectError('Route "/" used `searchParams.foo`')
229214
expectError('Error occurred prerendering page "/"')
230215
expectError('Error: Route "/" could not be prerendered.')
231216
expectError('exiting the build.')
@@ -313,14 +298,7 @@ function runTests(options: { withMinification: boolean }) {
313298
}
314299
const expectError = createExpectError(next.cliOutput)
315300

316-
expectError(
317-
"Error: Route \"/\" used cookies().get('token'). `cookies()` now returns a Promise and should be `awaited` before using it's value. See more info here: https://nextjs.org/docs/messages/next-prerender-sync-headers"
318-
)
319-
expectError(
320-
'Error: In Route "/" this parent component stack may help you locate where cookies().get(\'token\') was used.',
321-
// Turbopack doesn't support disabling minification yet
322-
withMinification || isTurbopack ? undefined : 'IndirectionTwo'
323-
)
301+
expectError('Route "/" used `cookies().get(\'token\')`')
324302
expectError('Error occurred prerendering page "/"')
325303
expectError('Route "/" could not be prerendered.')
326304
expectError('exiting the build.')

0 commit comments

Comments
 (0)