import * as vscode from 'vscode' ; import { TestRunner , TestRunType } from '../testRunner' ; import { TestDirectoryInfo , TestExecutionInfo , TestFileInfo , TestInfoKind , TestType } from '../types' ; import { FORCE_LWC_TEST_RUN_LOG_NAME } from '../types/constants' ; import { isLwcJestTest } from '../utils' ; import { getTestWorkspaceFolder } from '../workspace' ; param testExecutionInfo export async function forceLwcTestRun ( testExecutionInfo ) { const testRunner = new TestRunner ( testExecutionInfo , TestRunType . RUN , FORCE_LWC_TEST_RUN_LOG_NAME ) ; try { return await testRunner . executeAsSfdxTask ( ) ; } catch ( error ) { console . error ( error ) ; } } param data export function forceLwcTestCaseRun ( data ) { const { testExecutionInfo } = data ; return forceLwcTestRun ( testExecutionInfo ) ; } param data export function forceLwcTestFileRun ( data ) { const { testExecutionInfo } = data ; return forceLwcTestRun ( testExecutionInfo ) ; } /**
 * Run all tests in the workspace folder
 */ export function forceLwcTestRunAllTests ( ) { const workspaceFolder = getTestWorkspaceFolder ( ) ; if ( workspaceFolder ) { const testExecutionInfo = { kind : TestInfoKind . TEST_DIRECTORY , testType : TestType . LWC , testUri : workspaceFolder . uri } ; return forceLwcTestRun ( testExecutionInfo ) ; } } /**
 * Run the test of currently focused editor
 */ export function forceLwcTestRunActiveTextEditorTest ( ) { const { activeTextEditor } = vscode . window ; if ( activeTextEditor && isLwcJestTest ( activeTextEditor . document ) ) { const testExecutionInfo = { kind : TestInfoKind . TEST_FILE , testType : TestType . LWC , testUri : activeTextEditor . document . uri } ; return forceLwcTestFileRun ( { testExecutionInfo } ) ; } }