Skip to content

Commit

Permalink
Add failing test for next/link next/image with "type": "module"
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens authored and Brooooooklyn committed Apr 11, 2022
1 parent 1ed38dd commit b235254
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/e2e/type-module-interop/index.test.ts
Expand Up @@ -2,6 +2,7 @@ import { createNext } from 'e2e-utils'
import { NextInstance } from 'test/lib/next-modes/base'
import { hasRedbox, renderViaHTTP } from 'next-test-utils'
import webdriver from 'next-webdriver'
import cheerio from 'cheerio'

describe('Type module interop', () => {
let next: NextInstance
Expand All @@ -14,6 +15,21 @@ describe('Type module interop', () => {
return <p>hello world</p>
}
`,
'pages/modules.jsx': `
import Link from 'next/link'
import Image from 'next/image'
export default function Modules() {
return (
<>
<Link href="/">
<a id="link-to-home">link to home</a>
</Link>
<Image src="/static/image.png" width="100" height="100" />
</>
)
}
`,
},
dependencies: {},
})
Expand All @@ -39,4 +55,16 @@ describe('Type module interop', () => {
expect(await hasRedbox(browser)).toBe(false)
await browser.close()
})

it('should render server-side with modules', async () => {
const html = await renderViaHTTP(next.url, '/modules')
const $ = cheerio.load(html)
expect($('#link-to-home').text()).toBe('link to home')
})

it('should render client-side with modules', async () => {
const browser = await webdriver(next.url, '/modules')
expect(await hasRedbox(browser)).toBe(false)
await browser.close()
})
})

0 comments on commit b235254

Please sign in to comment.