mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 14:15:13 +00:00
fix tsconfig + remove forgotten duplicated test (#4886)
This commit is contained in:
parent
445d50c250
commit
774823ba41
@ -44,6 +44,9 @@ export async function setup(tsConfigPath) {
|
||||
}
|
||||
// https://github.com/TypeStrong/ts-node
|
||||
register({
|
||||
project: tsConfigPath
|
||||
project: tsConfigPath,
|
||||
compilerOptions: {
|
||||
module: 'commonjs'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -35,7 +35,10 @@ describe('typescript setup', () => {
|
||||
|
||||
expect(register).toHaveBeenCalledTimes(1)
|
||||
expect(register).toHaveBeenCalledWith({
|
||||
project: tsConfigPath
|
||||
project: tsConfigPath,
|
||||
compilerOptions: {
|
||||
module: 'commonjs'
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "esnext",
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"lib": [
|
||||
"esnext",
|
||||
|
@ -1,46 +0,0 @@
|
||||
import { resolve } from 'path'
|
||||
import { exists, mkdirp, readJSON, remove } from 'fs-extra'
|
||||
import { register } from 'ts-node'
|
||||
import { setup as setupTypeScript } from '@nuxt/typescript'
|
||||
|
||||
jest.mock('ts-node')
|
||||
|
||||
describe('typescript setup', () => {
|
||||
const rootDir = 'tmp'
|
||||
const tsConfigPath = resolve(rootDir, 'tsconfig.json')
|
||||
|
||||
beforeAll(async () => {
|
||||
// We're assuming that rootDir provided to setupTypeScript is existing so we create the tested one
|
||||
await mkdirp(rootDir)
|
||||
await setupTypeScript(tsConfigPath)
|
||||
})
|
||||
|
||||
test('tsconfig.json has been generated if missing', async () => {
|
||||
expect(await exists(tsConfigPath)).toBe(true)
|
||||
expect(await readJSON(tsConfigPath)).toEqual({
|
||||
extends: '@nuxt/typescript',
|
||||
compilerOptions: {
|
||||
baseUrl: '.',
|
||||
types: [
|
||||
'@types/node',
|
||||
'@nuxt/vue-app'
|
||||
]
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
test('ts-node has been registered once', async () => {
|
||||
// Call setupTypeScript a second time to test guard
|
||||
await setupTypeScript(tsConfigPath)
|
||||
|
||||
expect(register).toHaveBeenCalledTimes(1)
|
||||
expect(register).toHaveBeenCalledWith({
|
||||
project: tsConfigPath
|
||||
})
|
||||
})
|
||||
|
||||
afterAll(async () => {
|
||||
// Clean workspace by removing the temporary folder (and the generated tsconfig.json at the same time)
|
||||
await remove(tsConfigPath)
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user