Skip to content

Commit 6bd2b4f

Browse files
committed
Update tests
1 parent 1b28e3a commit 6bd2b4f

File tree

6 files changed

+23
-37
lines changed

6 files changed

+23
-37
lines changed

test/integration/dist-dir/test/index.test.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,9 @@ describe('distDir', () => {
6868

6969
it('should build the app within the given `dist` directory', async () => {
7070
// In isolated dev build, the distDir for development is `distDir/dev`
71-
if (process.env.__NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD === 'true') {
72-
expect(
73-
await fs.exists(join(__dirname, `/../dist/dev/${BUILD_MANIFEST}`))
74-
).toBeTruthy()
75-
} else {
76-
expect(
77-
await fs.exists(join(__dirname, `/../dist/${BUILD_MANIFEST}`))
78-
).toBeTruthy()
79-
}
71+
expect(
72+
await fs.exists(join(__dirname, `/../dist/dev/${BUILD_MANIFEST}`))
73+
).toBeTruthy()
8074
})
8175
it('should not build the app within the default `.next` directory', async () => {
8276
expect(

test/integration/module-ids/test/index.test.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import {
88
launchApp,
99
nextBuild,
1010
renderViaHTTP,
11+
getDistDir,
1112
} from 'next-test-utils'
1213

1314
const appDir = join(__dirname, '../')
14-
15+
const originalIsNextDev = global.isNextDev
1516
let appPort
1617
let app
1718

@@ -23,9 +24,11 @@ describe('minified module ids', () => {
2324
let staticBundles = ''
2425

2526
beforeAll(async () => {
27+
// getDistDir depends on global.isNextDev
28+
global.isNextDev = false
2629
await nextBuild(appDir, [])
2730

28-
const ssrPath = join(appDir, '.next/server/chunks/ssr/')
31+
const ssrPath = join(appDir, `${getDistDir()}/server/chunks/ssr/`)
2932
const ssrBundleBasenames = (await fs.readdir(ssrPath)).filter((p) =>
3033
p.match(/\.js$/)
3134
)
@@ -34,7 +37,7 @@ describe('minified module ids', () => {
3437
ssrBundles += output
3538
}
3639

37-
const staticPath = join(appDir, '.next/static/chunks/')
40+
const staticPath = join(appDir, `${getDistDir()}/static/chunks/`)
3841
const staticBundleBasenames = (await fs.readdir(staticPath)).filter((p) =>
3942
p.match(/\.js$/)
4043
)
@@ -43,6 +46,9 @@ describe('minified module ids', () => {
4346
staticBundles += output
4447
}
4548
})
49+
afterAll(() => {
50+
global.isNextDev = originalIsNextDev
51+
})
4652

4753
it('should have no long module ids for basic modules', async () => {
4854
expect(ssrBundles).not.toContain('module-with-long-name')
@@ -72,12 +78,14 @@ describe('minified module ids', () => {
7278
let staticBundles = ''
7379

7480
beforeAll(async () => {
81+
// getDistDir depends on global.isNextDev
82+
global.isNextDev = true
7583
appPort = await findPort()
7684
app = await launchApp(appDir, appPort)
7785

7886
await renderViaHTTP(appPort, '/')
7987

80-
const ssrPath = join(appDir, '.next/server/chunks/ssr/')
88+
const ssrPath = join(appDir, `${getDistDir()}/server/chunks/ssr/`)
8189
const ssrBundleBasenames = (await fs.readdir(ssrPath)).filter((p) =>
8290
p.match(/\.js$/)
8391
)
@@ -86,7 +94,7 @@ describe('minified module ids', () => {
8694
ssrBundles += output
8795
}
8896

89-
const staticPath = join(appDir, '.next/static/chunks/')
97+
const staticPath = join(appDir, `${getDistDir()}/static/chunks/`)
9098
const staticBundleBasenames = (await fs.readdir(staticPath)).filter((p) =>
9199
p.match(/\.js$/)
92100
)
@@ -95,7 +103,10 @@ describe('minified module ids', () => {
95103
staticBundles += output
96104
}
97105
})
98-
afterAll(() => killApp(app))
106+
afterAll(() => {
107+
global.isNextDev = originalIsNextDev
108+
killApp(app)
109+
})
99110

100111
it('should have long module ids for basic modules', async () => {
101112
expect(ssrBundles).toContain('module-with-long-name')
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
import "./.next/types/routes.d.ts";
3+
import "./.next/dev/types/routes.d.ts";
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/pages/api-reference/config/typescript for more information.

test/integration/typescript-app-type-declarations/test/index.test.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,6 @@ const appDir = join(__dirname, '..')
88
const appTypeDeclarations = join(appDir, 'next-env.d.ts')
99

1010
describe('TypeScript App Type Declarations', () => {
11-
if (process.env.__NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD === 'true') {
12-
it.skip('should skip on isolated dev build', () => {
13-
// We use static fixture "next-env.d.ts" but the content should differ
14-
// based on the isolated dev build flag. We can't do something like
15-
// "next-env-dev.d.ts" because Next.js Types Plugin emits a file
16-
// "next-env.d.ts", and we have to change its behavior for this test case.
17-
// Rather than that, just skip the test as we're going to remove this flag soon.
18-
// Then modify the content to be ".next/dev/types/routes.d.ts"
19-
})
20-
return
21-
}
22-
2311
it('should write a new next-env.d.ts if none exist', async () => {
2412
const prevContent = await fs.readFile(appTypeDeclarations, 'utf8')
2513
try {

test/lib/next-test-utils.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,9 +1893,7 @@ export function normalizeManifest<T>(
18931893
export function getDistDir(): '.next' | '.next/dev' {
18941894
// global.isNextDev is set in e2e/development/production tests.
18951895
// NEXT_TEST_MODE is set in CI or local test-* commands.
1896-
return ((global as any).isNextDev || process.env.NEXT_TEST_MODE === 'dev') &&
1897-
// Flag for incremental rollout of isolated dev build, set in CI.
1898-
process.env.__NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD === 'true'
1896+
return (global as any).isNextDev || process.env.NEXT_TEST_MODE === 'dev'
18991897
? '.next/dev'
19001898
: '.next'
19011899
}

test/unit/isolated/config.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,7 @@ describe('config', () => {
3838

3939
it('Should assign object defaults deeply to user config', async () => {
4040
const config = await loadConfig(PHASE_DEVELOPMENT_SERVER, pathToConfigFn)
41-
// In isolatedDevBuild, the default distDir is ".next/dev" during PHASE_DEVELOPMENT_SERVER.
42-
if (process.env.__NEXT_EXPERIMENTAL_ISOLATED_DEV_BUILD === 'true') {
43-
expect(config.distDir).toEqual('.next/dev')
44-
} else {
45-
expect(config.distDir).toEqual('.next')
46-
}
41+
expect(config.distDir.replace(/\\/g, '/')).toEqual('.next/dev')
4742
expect(config.onDemandEntries.maxInactiveAge).toBeDefined()
4843
})
4944

0 commit comments

Comments
 (0)