Unverified Commit 7126b066 authored by Steven's avatar Steven Committed by GitHub

chore: split up app-dir-export tests (#48252)

This splits the tests up a little more and avoids the need for env vars
parent ce42173e
process.env.TEST_DEV = '1'
require('./dynamic')
import { runTests } from './utils'
it.each([
{ isDev: true, dynamic: 'undefined' },
{ isDev: true, dynamic: "'error'" },
{ isDev: true, dynamic: "'force-static'" },
{
isDev: true,
dynamic: "'force-dynamic'",
expectedErrMsg:
'Page with `dynamic = "force-dynamic"` couldn\'t be rendered statically because it used `output: export`.',
},
{ isDev: false, dynamic: 'undefined' },
{ isDev: false, dynamic: "'error'" },
{ isDev: false, dynamic: "'force-static'" },
// TODO: re-enable when flakey behavior is investigated
// {
// isDev: false,
// dynamic: "'force-dynamic'",
// expectedErrMsg:
// 'Page with `dynamic = "force-dynamic"` couldn\'t be rendered statically because it used `output: export`.',
// },
])(
"should work with with isDev '$isDev' and dynamic $dynamic on page",
async ({ isDev, dynamic, expectedErrMsg }) => {
await runTests({ isDev, dynamicPage: dynamic, expectedErrMsg })
}
)
it.each([
{ isDev: true, dynamic: 'undefined' },
{ isDev: true, dynamic: "'error'" },
{ isDev: true, dynamic: "'force-static'" },
{
isDev: true,
dynamic: "'force-dynamic'",
expectedErrMsg:
'export const dynamic = "force-dynamic" on page "/api/json" cannot be used with "output: export".',
},
{ isDev: false, dynamic: 'undefined' },
{ isDev: false, dynamic: "'error'" },
{ isDev: false, dynamic: "'force-static'" },
{
isDev: false,
dynamic: "'force-dynamic'",
expectedErrMsg:
'export const dynamic = "force-dynamic" on page "/api/json" cannot be used with "output: export".',
},
])(
"should work with with isDev '$isDev' and dynamic $dynamic on route handler",
async ({ isDev, dynamic, expectedErrMsg }) => {
await runTests({ isDev, dynamicApiRoute: dynamic, expectedErrMsg })
}
)
import { runTests } from './utils'
it.each([
{ dynamicApiRoute: 'undefined' },
{ dynamicApiRoute: "'error'" },
{ dynamicApiRoute: "'force-static'" },
{
dynamicApiRoute: "'force-dynamic'",
expectedErrMsg:
'export const dynamic = "force-dynamic" on page "/api/json" cannot be used with "output: export".',
},
])(
'should work in dev with dynamicApiRoute $dynamicApiRoute',
async ({ dynamicApiRoute, expectedErrMsg }) => {
await runTests({ isDev: true, dynamicApiRoute, expectedErrMsg })
}
)
import { runTests } from './utils'
it.each([
{ dynamicApiRoute: 'undefined' },
{ dynamicApiRoute: "'error'" },
{ dynamicApiRoute: "'force-static'" },
{
dynamicApiRoute: "'force-dynamic'",
expectedErrMsg:
'export const dynamic = "force-dynamic" on page "/api/json" cannot be used with "output: export".',
},
])(
'should work in prod with dynamicApiRoute $dynamicApiRoute',
async ({ dynamicApiRoute, expectedErrMsg }) => {
await runTests({ isDev: false, dynamicApiRoute, expectedErrMsg })
}
)
import { runTests } from './utils'
it.each([
{ dynamicPage: 'undefined' },
{ dynamicPage: "'error'" },
{ dynamicPage: "'force-static'" },
{
dynamicPage: "'force-dynamic'",
expectedErrMsg:
'Page with `dynamic = "force-dynamic"` couldn\'t be rendered statically because it used `output: export`.',
},
])(
'should work in dev with dynamicPage $dynamicPage',
async ({ dynamicPage, expectedErrMsg }) => {
await runTests({ isDev: true, dynamicPage, expectedErrMsg })
}
)
import { runTests } from './utils'
it.each([
{ dynamicPage: 'undefined' },
{ dynadynamicPagemic: "'error'" },
{ dynamicPage: "'force-static'" },
{
dynamicPage: "'force-dynamic'",
expectedErrMsg:
'Page with `dynamic = "force-dynamic"` couldn\'t be rendered statically because it used `output: export`.',
},
])(
'should work in prod with dynamicPage $dynamicPage',
async ({ dynamicPage, expectedErrMsg }) => {
await runTests({ isDev: false, dynamicPage, expectedErrMsg })
}
)
process.env.TEST_DEV = '1' import { runTests } from './utils'
require('./trailing-slash')
it.each([{ trailingSlash: false }, { trailingSlash: true }])(
"should work in dev with trailingSlash '$trailingSlash'",
async ({ trailingSlash }) => {
await runTests({ isDev: true, trailingSlash })
}
)
require('./trailing-slash') import { runTests } from './utils'
it.each([{ trailingSlash: false }, { trailingSlash: true }])(
"should work in prod with trailingSlash '$trailingSlash'",
async ({ trailingSlash }) => {
await runTests({ isDev: false, trailingSlash })
}
)
import { runTests } from './utils'
it.each([
{ isDev: true, trailingSlash: false },
{ isDev: true, trailingSlash: true },
{ isDev: false, trailingSlash: false },
{ isDev: false, trailingSlash: true },
])(
"should work with isDev '$isDev' and trailingSlash '$trailingSlash'",
async ({ isDev, trailingSlash }) => {
await runTests({ isDev, trailingSlash })
}
)
...@@ -74,9 +74,6 @@ export async function runTests({ ...@@ -74,9 +74,6 @@ export async function runTests({
dynamicApiRoute?: string dynamicApiRoute?: string
expectedErrMsg?: string expectedErrMsg?: string
}) { }) {
if ((isDev && !process.env.TEST_DEV) || (!isDev && process.env.TEST_DEV)) {
return
}
if (trailingSlash) { if (trailingSlash) {
nextConfig.replace( nextConfig.replace(
'trailingSlash: true,', 'trailingSlash: true,',
......
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