| import { nextTestSetup } from 'e2e-utils' |
|
|
| function normalize(str: string) { |
| return str.replace(/<!-- -->/g, '') |
| } |
|
|
| describe('esm-externals', () => { |
| const { next, isTurbopack } = nextTestSetup({ |
| files: __dirname, |
| }) |
|
|
| |
| describe.each(['/static', '/ssr', '/ssg'])('pages url %s', (url) => { |
| |
| |
| |
| const expectedHtml = isTurbopack |
| ? 'Hello World+World+World+World+World+World' |
| : url === '/static' |
| ? 'Hello World+World+Alternative+World+World+World' |
| : 'Hello World+World+Alternative+World+World+Alternative' |
|
|
| |
| const expectedText = |
| isTurbopack || url === '/static' |
| ? 'Hello World+World+World+World+World+World' |
| : 'Hello World+World+World+World+World+Alternative' |
|
|
| it('should return the correct SSR HTML', async () => { |
| const $ = await next.render$(url) |
| const body = $('body p').html() |
| expect(normalize(body)).toEqual(expectedHtml) |
| }) |
|
|
| it('should render the correct page', async () => { |
| const browser = await next.browser(url) |
| expect(await browser.elementByCss('body p').text()).toEqual(expectedText) |
| }) |
| }) |
|
|
| |
| describe.each(['/server', '/client'])('app dir url %s', (url) => { |
| const expectedHtml = isTurbopack |
| ? 'Hello World+World+World' |
| : 'Hello World+World+Alternative' |
|
|
| const expectedText = isTurbopack |
| ? 'Hello World+World+World' |
| : url === '/client' |
| ? 'Hello World+World+World' |
| : 'Hello World+World+Alternative' |
|
|
| it('should return the correct SSR HTML', async () => { |
| const $ = await next.render$(url) |
| const body = $('body > p').html() |
| expect(normalize(body)).toEqual(expectedHtml) |
| }) |
|
|
| it('should render the correct page', async () => { |
| const browser = await next.browser(url) |
| expect(await browser.elementByCss('body > p').text()).toEqual( |
| expectedText |
| ) |
| }) |
| }) |
| }) |
|
|