@salesforce/salesforcedx-vscode-test-tools
Version:
Test automation framework for Salesforce Extensions for VS Code
51 lines • 2.21 kB
JavaScript
;
/*
* Copyright (c) 2025, salesforce.com, inc.
* All rights reserved.
* Licensed under the BSD 3-Clause license.
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.getTerminalView = getTerminalView;
exports.getTerminalViewText = getTerminalViewText;
exports.executeCommand = executeCommand;
const miscellaneous_1 = require("../core/miscellaneous");
/**
* Gets the terminal view from the workbench
* @param workbench - The VSCode workbench instance
* @returns A promise that resolves to the terminal view
*/
async function getTerminalView(workbench) {
const bottomBar = await workbench.getBottomBar().wait();
const terminalView = await (await bottomBar.openTerminalView()).wait();
return terminalView;
}
/**
* Gets the text content from the terminal view
* @param workbench - The VSCode workbench instance
* @param seconds - Number of seconds to wait before getting the text (allows time for terminal output)
* @returns A promise that resolves to the text content of the terminal
*/
async function getTerminalViewText(workbench, seconds) {
await (0, miscellaneous_1.pause)(miscellaneous_1.Duration.seconds(seconds));
const terminalView = await getTerminalView(workbench);
return await terminalView.getText();
}
/**
* Executes a command in the terminal
* @param workbench - The VSCode workbench instance
* @param command - The command to execute in the terminal
* @returns A promise that resolves to the terminal view
* @throws Error if the terminal view cannot be obtained
*/
async function executeCommand(workbench, command) {
(0, miscellaneous_1.log)(`Executing the command, "${command}"`);
const terminalView = await (await getTerminalView(workbench)).wait();
if (!terminalView) {
throw new Error('In executeCommand(), the terminal view returned from getTerminalView() was null (or undefined)');
}
await (0, miscellaneous_1.pause)(miscellaneous_1.Duration.seconds(5));
await terminalView.executeCommand(command);
return terminalView;
}
//# sourceMappingURL=terminalView.js.map