forked from vercel/next.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.test.ts
41 lines (34 loc) · 1.09 KB
/
index.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { createNext } from 'e2e-utils'
import fs from 'fs'
import { waitFor } from 'next-test-utils'
import path from 'path'
import { NextInstance } from 'test/lib/next-modes/base'
describe('correct tsconfig.json defaults', () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {
'pages/index.tsx': 'export default function Page() {}',
},
skipStart: true,
dependencies: {
typescript: '4.7.4',
'@types/react': 'latest',
'@types/node': 'latest',
},
})
})
afterAll(() => next.destroy())
it('should add `moduleResoution` when generating tsconfig.json in dev', async () => {
const tsconfigPath = path.join(next.testDir, 'tsconfig.json')
expect(fs.existsSync(tsconfigPath)).toBeFalse()
await next.start()
await waitFor(1000)
await next.stop()
expect(fs.existsSync(tsconfigPath)).toBeTrue()
const tsconfig = JSON.parse(await next.readFile('tsconfig.json'))
expect(tsconfig.compilerOptions).toEqual(
expect.objectContaining({ moduleResolution: 'node' })
)
})
})