From b23525400ebdc669eb0064a51aaf380222f217f4 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Wed, 16 Feb 2022 11:15:26 +0100 Subject: [PATCH] Add failing test for next/link next/image with "type": "module" --- test/e2e/type-module-interop/index.test.ts | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/e2e/type-module-interop/index.test.ts b/test/e2e/type-module-interop/index.test.ts index 21e13a32586b..918ceaef1151 100644 --- a/test/e2e/type-module-interop/index.test.ts +++ b/test/e2e/type-module-interop/index.test.ts @@ -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 @@ -14,6 +15,21 @@ describe('Type module interop', () => { return

hello world

} `, + 'pages/modules.jsx': ` + import Link from 'next/link' + import Image from 'next/image' + + export default function Modules() { + return ( + <> + + link to home + + + + ) + } + `, }, dependencies: {}, }) @@ -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() + }) })