Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsorban44 committed Jul 14, 2022
1 parent fca9e5f commit 12b4516
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/integration/create-next-app/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/* eslint-env jest */
import { execSync } from 'child_process'
import execa from 'execa'
import fs from 'fs-extra'
import { killApp, launchApp, findPort, waitFor } from 'next-test-utils'
import os from 'os'
import path from 'path'

Expand Down Expand Up @@ -482,4 +484,38 @@ describe('create next app', () => {
)
})
})

it.only('should add `moduleResoution` when generating tsconfig.json', async () => {
await usingTempDir(async (cwd) => {
const projectName = 'tsconfig-generation'
const res = await run([projectName], { cwd })
expect(res.exitCode).toBe(0)

const tsconfigPath = path.join(cwd, projectName, 'tsconfig.json')
expect(fs.existsSync(tsconfigPath)).toBeFalse()

await execSync('pnpm add -D typescript @types/react', {
cwd: path.join(cwd, projectName),
})

const indexPath = path.join(cwd, projectName, 'pages', 'index.js')
await fs.rename(indexPath, indexPath.replace('.js', '.tsx'))

const appPort = await findPort()
const app = await launchApp(path.join(cwd, projectName), appPort)
await killApp(app)

expect(fs.existsSync(tsconfigPath)).toBeTrue()

const tsconfig = JSON.parse(
await fs.readFile(path.join(cwd, projectName, 'tsconfig.json'), 'utf8')
)

expect(tsconfig.compilerOptions).toEqual(
expect.objectContaining({
moduleResolution: 'node',
})
)
})
})
})

0 comments on commit 12b4516

Please sign in to comment.