diff --git a/packages/language-service/tests/utils/createTester.ts b/packages/language-service/tests/utils/createTester.ts index f048b61330..85d1cde289 100644 --- a/packages/language-service/tests/utils/createTester.ts +++ b/packages/language-service/tests/utils/createTester.ts @@ -9,18 +9,19 @@ import { createMockServiceEnv } from './mockEnv'; const testRoot = path.resolve(__dirname, '../../../../test-workspace/language-service').replace(/\\/g, '/'); export const rootUri = URI.file(testRoot); -export const tester = createTester(testRoot); +export const tester = createTester(rootUri); -function createTester(root: string) { +function createTester(rootUri: URI) { const ts = require('typescript') as typeof import('typescript/lib/tsserverlibrary'); - const realTsConfig = path.join(root, 'tsconfig.json').replace(/\\/g, '/'); + const serviceEnv = createMockServiceEnv(rootUri, () => currentVSCodeSettings ?? defaultVSCodeSettings); + const rootPath = serviceEnv.uriToFileName(rootUri.toString()); + const realTsConfig = path.join(rootPath, 'tsconfig.json').replace(/\\/g, '/'); const parsedCommandLine = createParsedCommandLine(ts, ts.sys, realTsConfig); parsedCommandLine.fileNames = parsedCommandLine.fileNames.map(fileName => fileName.replace(/\\/g, '/')); const scriptSnapshots = new Map(); - const serviceEnv = createMockServiceEnv(rootUri, () => currentVSCodeSettings ?? defaultVSCodeSettings); const languageHost: TypeScriptProjectHost = { - getCurrentDirectory: () => root, + getCurrentDirectory: () => rootPath, getProjectVersion: () => '0', getScriptFileNames: () => parsedCommandLine.fileNames, getCompilationSettings: () => parsedCommandLine.options,