Skip to content

Commit c86ed94

Browse files
committed
add test
1 parent fca9e5f commit c86ed94

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

test/integration/create-next-app/index.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/* eslint-env jest */
2+
import { execSync } from 'child_process'
23
import execa from 'execa'
34
import fs from 'fs-extra'
5+
import { killApp, launchApp, findPort, waitFor } from 'next-test-utils'
46
import os from 'os'
57
import path from 'path'
68

@@ -482,4 +484,38 @@ describe('create next app', () => {
482484
)
483485
})
484486
})
487+
488+
it('should add `moduleResoution` when generating tsconfig.json', async () => {
489+
await usingTempDir(async (cwd) => {
490+
const projectName = 'tsconfig-generation'
491+
const res = await run([projectName], { cwd })
492+
expect(res.exitCode).toBe(0)
493+
494+
const tsconfigPath = path.join(cwd, projectName, 'tsconfig.json')
495+
expect(fs.existsSync(tsconfigPath)).toBeFalse()
496+
497+
await execSync('pnpm add -D typescript @types/react', {
498+
cwd: path.join(cwd, projectName),
499+
})
500+
501+
const indexPath = path.join(cwd, projectName, 'pages', 'index.js')
502+
await fs.rename(indexPath, indexPath.replace('.js', '.tsx'))
503+
504+
const appPort = await findPort()
505+
const app = await launchApp(path.join(cwd, projectName), appPort)
506+
await killApp(app)
507+
508+
expect(fs.existsSync(tsconfigPath)).toBeTrue()
509+
510+
const tsconfig = JSON.parse(
511+
await fs.readFile(path.join(cwd, projectName, 'tsconfig.json'), 'utf8')
512+
)
513+
514+
expect(tsconfig.compilerOptions).toEqual(
515+
expect.objectContaining({
516+
moduleResolution: 'node',
517+
})
518+
)
519+
})
520+
})
485521
})

0 commit comments

Comments
 (0)