MCPcopy Create free account
hub / github.com/angular/angular / startTestServer

Function startTestServer

ngp-vscode-ng-language-service/tests/test_helpers.ts:70–175  ·  view source on GitHub ↗
(workspacePath: string)

Source from the content-addressed store, hash-verified

68}
69
70export async function startTestServer(workspacePath: string) {
71 console.log('[LSP TEST DEBUG] Starting tsgo...');
72 // 1. Find and spawn tsgo (TS 7 server)
73 const {connection: tsgoConnection, cleanup: tsgoCleanup} = await startTsgo(workspacePath);
74
75 console.log('[LSP TEST DEBUG] tsgo started. Spawning hybrid server...');
76 // 2. Find and spawn our server (Hybrid server)
77 const serverPath = await resolveServerPath();
78
79 // The server locates the analysis engine through this variable; make sure it is
80 // set even when no outer runner (e.g. `wasm_binding.mjs`) has done so.
81 const wasmBinding = resolveWasmBinding();
82 const serverEnv = {...process.env};
83 if (wasmBinding) {
84 serverEnv['NG_EXP_COMPILER_WASM_BINDING'] = wasmBinding;
85 }
86
87 const serverProcess = cp.spawn(process.execPath, [serverPath, '--stdio'], {
88 stdio: ['pipe', 'pipe', 'inherit'],
89 cwd: workspacePath,
90 env: serverEnv,
91 });
92
93 const connection = rpc.createMessageConnection(
94 new rpc.StreamMessageReader(serverProcess.stdout!),
95 new rpc.StreamMessageWriter(serverProcess.stdin!),
96 );
97
98 connection.onNotification('window/logMessage', (params: any) => {
99 console.log(`[Server Log] ${params.message}`);
100 });
101
102 connection.onRequest(
103 'angular/sendTsServerRequest',
104 async (params: {method: string; params: any}) => {
105 return tsgoConnection.sendRequest(params.method, params.params);
106 },
107 );
108
109 connection.onNotification(
110 'angular/sendTsServerNotification',
111 async (params: {method: string; params: any}) => {
112 tsgoConnection.sendNotification(params.method, params.params);
113 },
114 );
115
116 connection.listen();
117
118 let apiPipe: string | undefined;
119 try {
120 const apiSession = await tsgoConnection.sendRequest<{sessionId: string; pipe: string}>(
121 'custom/initializeAPISession',
122 {},
123 );
124 apiPipe = apiSession?.pipe;
125 } catch (err) {
126 console.error('Failed to initialize API session in test tsgo:', err);
127 }

Calls 10

startTsgoFunction · 0.90
resolveWasmBindingFunction · 0.90
resolveServerPathFunction · 0.85
setTimeoutFunction · 0.85
raceMethod · 0.80
killMethod · 0.80
logMethod · 0.65
listenMethod · 0.65
errorMethod · 0.65
spawnMethod · 0.45

Tested by

no test coverage detected