Repository: vercel/next.js
Pull request: test: split app-middleware test per describe

A single test file is starting 3 next instances sequentially. This can be paralleled from different test files. This PR splits tests per "describe" and does not change its content.

Changed files:
filename: test/e2e/app-dir/app-middleware/app-middleware-in-src-dir.test.ts
patch: @@ -0,0 +1,34 @@
+/* eslint-env jest */
+import path from 'path'
+import { nextTestSetup, FileRef } from 'e2e-utils'
+
+describe('app dir - middleware with middleware in src dir', () => {
+  const { next } = nextTestSetup({
+    files: {
+      'src/app': new FileRef(path.join(__dirname, 'app')),
+      'next.config.js': new FileRef(path.join(__dirname, 'next.config.js')),
+      'src/middleware.js': `
+      import { NextResponse } from 'next/server'
+      import { cookies } from 'next/headers'
+
+      export async function middleware(request) {
+        const cookie = (await cookies()).get('test-cookie')
+        return NextResponse.json({ cookie })
+      }
+    `,
+    },
+  })
+
+  it('works without crashing when using RequestStore', async () => {
+    const browser = await next.browser('/')
+    await browser.addCookie({
+      name: 'test-cookie',
+      value: 'test-cookie-response',
+    })
+    await browser.refresh()
+
+    const html = await browser.eval('document.documentElement.innerHTML')
+
+    expect(html).toContain('test-cookie-response')
+  })
+})

filename: test/e2e/app-dir/app-middleware/app-middleware-without-pages-dir.test.ts
patch: @@ -0,0 +1,29 @@
+/* eslint-env jest */
+import path from 'path'
+import { nextTestSetup, FileRef } from 'e2e-utils'
+
+describe('app dir - middleware without pages dir', () => {
+  const { next } = nextTestSetup({
+    files: {
+      app: new FileRef(path.join(__dirname, 'app')),
+      'next.config.js': new FileRef(path.join(__dirname, 'next.config.js')),
+      'middleware.js': `
+      import { NextResponse } from 'next/server'
+
+      export async function middleware(request) {
+        return new NextResponse('redirected')
+      }
+
+      export const config = {
+        matcher: '/headers'
+      }
+    `,
+    },
+  })
+
+  it('Updates headers', async () => {
+    const html = await next.render('/headers')
+
+    expect(html).toContain('redirected')
+  })
+})

filename: test/e2e/app-dir/app-middleware/app-middleware.test.ts
patch: @@ -1,8 +1,7 @@
 /* eslint-env jest */
-import path from 'path'
 import cheerio from 'cheerio'
 import { check, retry, withQuery } from 'next-test-utils'
-import { nextTestSetup, FileRef } from 'e2e-utils'
+import { nextTestSetup } from 'e2e-utils'
 import type { Response } from 'node-fetch'
 
 describe('app-dir with middleware', () => {
@@ -272,61 +271,3 @@ describe('app-dir with middleware', () => {
     })
   }
 })
-
-describe('app dir - middleware without pages dir', () => {
-  const { next } = nextTestSetup({
-    files: {
-      app: new FileRef(path.join(__dirname, 'app')),
-      'next.config.js': new FileRef(path.join(__dirname, 'next.config.js')),
-      'middleware.js': `
-      import { NextResponse } from 'next/server'
-
-      export async function middleware(request) {
-        return new NextResponse('redirected')
-      }
-
-      export const config = {
-        matcher: '/headers'
-      }
-    `,
-    },
-  })
-
-  // eslint-disable-next-line jest/no-identical-title
-  it('Updates headers', async () => {
-    const html = await next.render('/headers')
-
-    expect(html).toContain('redirected')
-  })
-})
-
-describe('app dir - middleware with middleware in src dir', () => {
-  const { next } = nextTestSetup({
-    files: {
-      'src/app': new FileRef(path.join(__dirname, 'app')),
-      'next.config.js': new FileRef(path.join(__dirname, 'next.config.js')),
-      'src/middleware.js': `
-      import { NextResponse } from 'next/server'
-      import { cookies } from 'next/headers'
-
-      export async function middleware(request) {
-        const cookie = (await cookies()).get('test-cookie')
-        return NextResponse.json({ cookie })
-      }
-    `,
-    },
-  })
-
-  it('works without crashing when using RequestStore', async () => {
-    const browser = await next.browser('/')
-    await browser.addCookie({
-      name: 'test-cookie',
-      value: 'test-cookie-response',
-    })
-    await browser.refresh()
-
-    const html = await browser.eval('document.documentElement.innerHTML')
-
-    expect(html).toContain('test-cookie-response')
-  })
-})

filename: test/experimental-tests-manifest.json
patch: @@ -122,6 +122,8 @@
       "test/e2e/app-dir/app-inline-css/index.test.ts",
       "test/e2e/app-dir/app-invalid-revalidate/app-invalid-revalidate.test.ts",
       "test/e2e/app-dir/app-middleware/app-middleware.test.ts",
+      "test/e2e/app-dir/app-middleware/app-middleware-in-src-dir.test.ts",
+      "test/e2e/app-dir/app-middleware/app-middleware-without-pages-dir.test.ts",
       "test/e2e/app-dir/app-prefetch*/**/*",
       "test/e2e/app-dir/app-rendering/rendering.test.ts",
       "test/e2e/app-dir/app-root-params/generate-static-params.test.ts",