Commit dafdc81b authored by Janka Uryga's avatar Janka Uryga

test: convert app-external.test.ts to nextTestSetup

parent 2c80812e
import { createNextDescribe } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { check, hasRedbox, retry, shouldRunTurboDevTest } from 'next-test-utils' import { check, hasRedbox, retry, shouldRunTurboDevTest } from 'next-test-utils'
async function resolveStreamResponse(response: any, onData?: any) { async function resolveStreamResponse(response: any, onData?: any) {
...@@ -15,9 +15,8 @@ async function resolveStreamResponse(response: any, onData?: any) { ...@@ -15,9 +15,8 @@ async function resolveStreamResponse(response: any, onData?: any) {
return result return result
} }
createNextDescribe( describe('app dir - external dependency', () => {
'app dir - external dependency', const { next, skipped, isTurbopack } = nextTestSetup({
{
files: __dirname, files: __dirname,
dependencies: { dependencies: {
swr: 'latest', swr: 'latest',
...@@ -34,8 +33,12 @@ createNextDescribe( ...@@ -34,8 +33,12 @@ createNextDescribe(
startCommand: (global as any).isNextDev ? 'pnpm dev' : 'pnpm start', startCommand: (global as any).isNextDev ? 'pnpm dev' : 'pnpm start',
buildCommand: 'pnpm build', buildCommand: 'pnpm build',
skipDeployment: true, skipDeployment: true,
}, })
({ next, isTurbopack }) => {
if (skipped) {
return
}
it('should be able to opt-out 3rd party packages being bundled in server components', async () => { it('should be able to opt-out 3rd party packages being bundled in server components', async () => {
await next.fetch('/react-server/optout').then(async (response) => { await next.fetch('/react-server/optout').then(async (response) => {
const result = await resolveStreamResponse(response) const result = await resolveStreamResponse(response)
...@@ -156,9 +159,7 @@ createNextDescribe( ...@@ -156,9 +159,7 @@ createNextDescribe(
async () => { async () => {
const browser = await next.browser('/browser') const browser = await next.browser('/browser')
// eslint-disable-next-line jest/no-standalone-expect // eslint-disable-next-line jest/no-standalone-expect
expect(await browser.elementByCss('#worker-state').text()).toBe( expect(await browser.elementByCss('#worker-state').text()).toBe('default')
'default'
)
await browser.elementByCss('button').click() await browser.elementByCss('button').click()
...@@ -180,9 +181,7 @@ createNextDescribe( ...@@ -180,9 +181,7 @@ createNextDescribe(
expect(v1).toBe(v2) expect(v1).toBe(v2)
// Should work with both esm and cjs imports // Should work with both esm and cjs imports
expect(html).toContain( expect(html).toContain('CJS-ESM Compat package: cjs-esm-compat/index.mjs')
'CJS-ESM Compat package: cjs-esm-compat/index.mjs'
)
expect(html).toContain('CJS package: cjs-lib') expect(html).toContain('CJS package: cjs-lib')
expect(html).toContain( expect(html).toContain(
'Nested imports: nested-import:esm:cjs-esm-compat/index.mjs' 'Nested imports: nested-import:esm:cjs-esm-compat/index.mjs'
...@@ -197,9 +196,7 @@ createNextDescribe( ...@@ -197,9 +196,7 @@ createNextDescribe(
expect(v1).toBe(v2) expect(v1).toBe(v2)
// Should work with both esm and cjs imports // Should work with both esm and cjs imports
expect(html).toContain( expect(html).toContain('CJS-ESM Compat package: cjs-esm-compat/index.mjs')
'CJS-ESM Compat package: cjs-esm-compat/index.mjs'
)
expect(html).toContain('CJS package: cjs-lib') expect(html).toContain('CJS package: cjs-lib')
}) })
...@@ -211,9 +208,7 @@ createNextDescribe( ...@@ -211,9 +208,7 @@ createNextDescribe(
expect(v1).toBe(v2) expect(v1).toBe(v2)
// Should work with both esm and cjs imports // Should work with both esm and cjs imports
expect(html).toContain( expect(html).toContain('CJS-ESM Compat package: cjs-esm-compat/index.mjs')
'CJS-ESM Compat package: cjs-esm-compat/index.mjs'
)
expect(html).toContain('CJS package: cjs-lib') expect(html).toContain('CJS package: cjs-lib')
}) })
...@@ -320,5 +315,4 @@ createNextDescribe( ...@@ -320,5 +315,4 @@ createNextDescribe(
expect(text).toBe('get route') expect(text).toBe('get route')
}) })
}) })
} })
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment