Files
angular__angular/vscode-ng-language-service/integration/e2e/definition_spec.ts
T
Alan Agius 8146fc2817 test: fix vscode language service e2e tests (#64197)
Fix the e2e test suite for the vscode language service extension and run it in CI.

PR Close #64197
2025-10-02 13:03:24 -07:00

38 lines
1.2 KiB
TypeScript

import * as vscode from 'vscode';
import {APP_COMPONENT} from '../test_constants';
import {activate} from './helper';
const DEFINITION_COMMAND = 'vscode.executeDefinitionProvider';
const APP_COMPONENT_URI = vscode.Uri.file(APP_COMPONENT);
describe('Angular LS', () => {
beforeAll(async () => {
await activate(APP_COMPONENT_URI);
}, 20_000);
it(`returns definition for variable in template`, async () => {
// vscode Position is zero-based
// template: `<h1>Hello {{name}}</h1>`,
// ^-------- here
const position = new vscode.Position(4, 25);
// For a complete list of standard commands, see
// https://code.visualstudio.com/api/references/commands
const definitions = await vscode.commands.executeCommand<vscode.LocationLink[]>(
DEFINITION_COMMAND,
APP_COMPONENT_URI,
position,
);
expect(definitions?.length).toBe(1);
const def = definitions![0];
expect(def.targetUri.fsPath).toBe(APP_COMPONENT); // in the same document
const {start, end} = def.targetRange;
// Should start and end on line 6
expect(start.line).toBe(8);
expect(end.line).toBe(8);
expect(start.character).toBe(2);
expect(end.character).toBe(start.character + `name`.length);
});
});