Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
Gracefully handle test commands run with no arguments
Browse files Browse the repository at this point in the history
If a test command is run with no arguments (for example, through a keybinding, or via the command palette), then we fall back to finding the correct arguments by finding the test item by active line.
  • Loading branch information
paracycle committed Jul 13, 2023
1 parent 916f306 commit 40d9afc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/testController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ export class TestController {
_name: string,
command: string
) {
// eslint-disable-next-line no-param-reassign
command ??= this.testCommands.get(this.findTestByActiveLine()!) || "";

await this.telemetry.sendCodeLensEvent("test_in_terminal");

if (this.terminal === undefined) {
Expand Down Expand Up @@ -276,6 +279,10 @@ export class TestController {
testId: string,
testItems: vscode.TestItemCollection = this.testController.items
) {
if (!testId) {
return this.findTestByActiveLine();
}

let testItem = testItems.get(testId);

if (testItem) return testItem;
Expand Down

0 comments on commit 40d9afc

Please sign in to comment.