Skip to content

Commit

Permalink
Update createTester.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Dec 6, 2023
1 parent 1a9470d commit 39f3e83
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions packages/language-service/tests/utils/createTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, ts.IScriptSnapshot>();
const serviceEnv = createMockServiceEnv(rootUri, () => currentVSCodeSettings ?? defaultVSCodeSettings);
const languageHost: TypeScriptProjectHost = {
getCurrentDirectory: () => root,
getCurrentDirectory: () => rootPath,
getProjectVersion: () => '0',
getScriptFileNames: () => parsedCommandLine.fileNames,
getCompilationSettings: () => parsedCommandLine.options,
Expand Down

0 comments on commit 39f3e83

Please sign in to comment.