@@ -120,7 +120,7 @@ if (!(globalThis as any).isNextDev) {
...
@@ -120,7 +120,7 @@ if (!(globalThis as any).isNextDev) {
constbrowser=awaitnext.browser(
constbrowser=awaitnext.browser(
'/server-with-errors/client-only-in-server'
'/server-with-errors/client-only-in-server'
)
)
awaithasRedbox(browser)
expect(awaithasRedbox(browser,true)).toBe(true)
consttext=awaitgetRedboxSource(browser)
consttext=awaitgetRedboxSource(browser)
expect(text).toContain(
expect(text).toContain(
`You're importing a component that imports client-only. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.`
`You're importing a component that imports client-only. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.`
...
@@ -132,7 +132,7 @@ if (!(globalThis as any).isNextDev) {
...
@@ -132,7 +132,7 @@ if (!(globalThis as any).isNextDev) {
'/client-with-errors/server-only-in-client'
'/client-with-errors/server-only-in-client'
)
)
awaithasRedbox(browser)
expect(awaithasRedbox(browser,true)).toBe(true)
consttext=awaitgetRedboxSource(browser)
consttext=awaitgetRedboxSource(browser)
expect(text).toContain(
expect(text).toContain(
`You're importing a component that needs server-only. That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component.`
`You're importing a component that needs server-only. That only works in a Server Component but one of its parents is marked with "use client", so it's a Client Component.`
...
@@ -140,10 +140,14 @@ if (!(globalThis as any).isNextDev) {
...
@@ -140,10 +140,14 @@ if (!(globalThis as any).isNextDev) {
})
})
it('should error for invalid undefined module retuning from next dynamic',async()=>{
it('should error for invalid undefined module retuning from next dynamic',async()=>{
// TODO: investigate previous error not being cleared properly
'"InstanceInitialPropsPage.getInitialProps()" is defined as an instance method - visit https://nextjs.org/docs/messages/get-initial-props-as-an-instance-method for more information.'
'"InstanceInitialPropsPage.getInitialProps()" is defined as an instance method - visit https://nextjs.org/docs/messages/get-initial-props-as-an-instance-method for more information.'
'Invalid src prop (https://google.com/test.png) on `next/image`, hostname "google.com" is not configured under images in your `next.config.js`'
'Invalid src prop (https://google.com/test.png) on `next/image`, hostname "google.com" is not configured under images in your `next.config.js`'
)
)
...
@@ -406,7 +406,7 @@ function runTests(mode) {
...
@@ -406,7 +406,7 @@ function runTests(mode) {
'/docs/invalid-src-proto-relative'
'/docs/invalid-src-proto-relative'
)
)
expect(awaithasRedbox(browser)).toBe(true)
expect(awaithasRedbox(browser,true)).toBe(true)
expect(awaitgetRedboxHeader(browser)).toContain(
expect(awaitgetRedboxHeader(browser)).toContain(
'Failed to parse src "//assets.example.com/img.jpg" on `next/image`, protocol-relative URL (//) must be changed to an absolute URL (http:// or https://)'
'Failed to parse src "//assets.example.com/img.jpg" on `next/image`, protocol-relative URL (//) must be changed to an absolute URL (http:// or https://)'
'Failed to parse src "//assets.example.com/img.jpg" on `next/image`, protocol-relative URL (//) must be changed to an absolute URL (http:// or https://)'
'Failed to parse src "//assets.example.com/img.jpg" on `next/image`, protocol-relative URL (//) must be changed to an absolute URL (http:// or https://)'
)
)
...
@@ -787,7 +787,7 @@ function runTests(mode) {
...
@@ -787,7 +787,7 @@ function runTests(mode) {
it('should show error when string src and placeholder=blur and blurDataURL is missing',async()=>{
it('should show error when string src and placeholder=blur and blurDataURL is missing',async()=>{
},/Image with src (.*)jpg(.*) may not render properly as a child of a flex container. Consider wrapping the image with a div to configure the width/gm)
},/Image with src (.*)jpg(.*) may not render properly as a child of a flex container. Consider wrapping the image with a div to configure the width/gm)
expect(awaithasRedbox(browser)).toBe(false)
expect(awaithasRedbox(browser,false)).toBe(false)
})
})
it('should warn when img with layout=fill is inside a container without position relative',async()=>{
it('should warn when img with layout=fill is inside a container without position relative',async()=>{
...
@@ -845,7 +845,7 @@ function runTests(mode) {
...
@@ -845,7 +845,7 @@ function runTests(mode) {
expect(warnings).not.toMatch(
expect(warnings).not.toMatch(
/Image with src (.*)webp(.*) may not render properly/gm
/Image with src (.*)webp(.*) may not render properly/gm
)
)
expect(awaithasRedbox(browser)).toBe(false)
expect(awaithasRedbox(browser,false)).toBe(false)
})
})
it('should warn when using a very small image with placeholder=blur',async()=>{
it('should warn when using a very small image with placeholder=blur',async()=>{
...
@@ -854,7 +854,7 @@ function runTests(mode) {
...
@@ -854,7 +854,7 @@ function runTests(mode) {
constwarnings=(awaitbrowser.log())
constwarnings=(awaitbrowser.log())
.map((log)=>log.message)
.map((log)=>log.message)
.join('\n')
.join('\n')
expect(awaithasRedbox(browser)).toBe(false)
expect(awaithasRedbox(browser,false)).toBe(false)
expect(warnings).toMatch(
expect(warnings).toMatch(
/Image with src (.*)jpg(.*) is smaller than 40x40. Consider removing(.*)/gm
/Image with src (.*)jpg(.*) is smaller than 40x40. Consider removing(.*)/gm
)
)
...
@@ -866,7 +866,7 @@ function runTests(mode) {
...
@@ -866,7 +866,7 @@ function runTests(mode) {
constwarnings=(awaitbrowser.log())
constwarnings=(awaitbrowser.log())
.map((log)=>log.message)
.map((log)=>log.message)
.join('\n')
.join('\n')
expect(awaithasRedbox(browser)).toBe(false)
expect(awaithasRedbox(browser,false)).toBe(false)
expect(warnings).not.toMatch(
expect(warnings).not.toMatch(
/Expected server HTML to contain a matching/gm
/Expected server HTML to contain a matching/gm
)
)
...
@@ -891,7 +891,7 @@ function runTests(mode) {
...
@@ -891,7 +891,7 @@ function runTests(mode) {
constwarnings=(awaitbrowser.log())
constwarnings=(awaitbrowser.log())
.map((log)=>log.message)
.map((log)=>log.message)
.join('\n')
.join('\n')
expect(awaithasRedbox(browser)).toBe(false)
expect(awaithasRedbox(browser,false)).toBe(false)
expect(warnings).toMatch(
expect(warnings).toMatch(
/Image with src (.*)wide.png(.*) was detected as the Largest Contentful Paint/gm
/Image with src (.*)wide.png(.*) was detected as the Largest Contentful Paint/gm
)
)
...
@@ -908,7 +908,7 @@ function runTests(mode) {
...
@@ -908,7 +908,7 @@ function runTests(mode) {
constwarnings=(awaitbrowser.log())
constwarnings=(awaitbrowser.log())
.map((log)=>log.message)
.map((log)=>log.message)
.join('\n')
.join('\n')
expect(awaithasRedbox(browser)).toBe(false)
expect(awaithasRedbox(browser,false)).toBe(false)
expect(warnings).toMatch(
expect(warnings).toMatch(
/Image with src (.*)png(.*) has a "loader" property that does not implement width/gm
/Image with src (.*)png(.*) has a "loader" property that does not implement width/gm
)
)
...
@@ -932,7 +932,7 @@ function runTests(mode) {
...
@@ -932,7 +932,7 @@ function runTests(mode) {
constwarnings=(awaitbrowser.log())
constwarnings=(awaitbrowser.log())
.map((log)=>log.message)
.map((log)=>log.message)
.join('\n')
.join('\n')
expect(awaithasRedbox(browser)).toBe(false)
expect(awaithasRedbox(browser,false)).toBe(false)
expect(warnings).toMatch(
expect(warnings).toMatch(
/Image with src (.*)png(.*) has "sizes" property but it will be ignored/gm
/Image with src (.*)png(.*) has "sizes" property but it will be ignored/gm
)
)
...
@@ -953,7 +953,7 @@ function runTests(mode) {
...
@@ -953,7 +953,7 @@ function runTests(mode) {
constwarnings=(awaitbrowser.log())
constwarnings=(awaitbrowser.log())
.map((log)=>log.message)
.map((log)=>log.message)
.join('\n')
.join('\n')
expect(awaithasRedbox(browser)).toBe(false)
expect(awaithasRedbox(browser,false)).toBe(false)
expect(warnings).not.toMatch(
expect(warnings).not.toMatch(
/Image with src (.*) has a "loader" property that does not implement width/gm
/Image with src (.*) has a "loader" property that does not implement width/gm
'Invalid src prop (https://google.com/test.png) on `next/image`, hostname "google.com" is not configured under images in your `next.config.js`'
'Invalid src prop (https://google.com/test.png) on `next/image`, hostname "google.com" is not configured under images in your `next.config.js`'
)
)
...
@@ -154,7 +154,7 @@ function runTests(mode) {
...
@@ -154,7 +154,7 @@ function runTests(mode) {
'/docs/invalid-src-proto-relative'
'/docs/invalid-src-proto-relative'
)
)
expect(awaithasRedbox(browser)).toBe(true)
expect(awaithasRedbox(browser,true)).toBe(true)
expect(awaitgetRedboxHeader(browser)).toContain(
expect(awaitgetRedboxHeader(browser)).toContain(
'Failed to parse src "//assets.example.com/img.jpg" on `next/image`, protocol-relative URL (//) must be changed to an absolute URL (http:// or https://)'
'Failed to parse src "//assets.example.com/img.jpg" on `next/image`, protocol-relative URL (//) must be changed to an absolute URL (http:// or https://)'
'Failed to parse src "//assets.example.com/img.jpg" on `next/image`, protocol-relative URL (//) must be changed to an absolute URL (http:// or https://)'
'Failed to parse src "//assets.example.com/img.jpg" on `next/image`, protocol-relative URL (//) must be changed to an absolute URL (http:// or https://)'
)
)
...
@@ -760,7 +760,7 @@ function runTests(mode) {
...
@@ -760,7 +760,7 @@ function runTests(mode) {
it('should show error when string src and placeholder=blur and blurDataURL is missing',async()=>{
it('should show error when string src and placeholder=blur and blurDataURL is missing',async()=>{