mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
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.
35 lines
1.0 KiB
TypeScript
35 lines
1.0 KiB
TypeScript
/* 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')
|
|
})
|
|
})
|