import { KarmaRunner } from "./karma/karma-runner" ; import { TestServerValidation } from "./test-server/test-server-validation" ; import { KarmaEventListener } from "./integration/karma-event-listener" ; import { Logger } from "./shared/logger" ; import { TestSuiteInfo } from "vscode-test-adapter-api" ; import { TestExplorerConfiguration } from "../model/test-explorer-configuration" ; import { TestServer } from "../model/test-server" ; export class AngularKarmaTestExplorer { private loadedProjectRootPath : string = "" ; public constructor ( private readonly karmaRunner , private readonly testServerValidation , private readonly logger , private readonly testServer , private readonly karmaEventListener ) { } public async loadTests ( config ) { if ( ! this . testServerValidation . isValidProject ( config . projectRootPath , config . projectType ) ) { return undefined ; } if ( this . karmaRunner . isKarmaRunning ( ) ) { await this . testServer . stopAsync ( ) ; } this . loadedProjectRootPath = await this . testServer . start ( config ) ; const testSuiteInfo = await this . karmaRunner . loadTests ( this . loadedProjectRootPath ) ; if ( testSuiteInfo . children . length === 0 ) { this . logger . info ( "Test loading completed - No tests found" ) ; } else { this . logger . info ( "Test loading completed" ) ; } return testSuiteInfo ; } public async reloadTestDefinitions ( ) { await this . karmaRunner . loadTests ( this . loadedProjectRootPath ) ; return await this . karmaRunner . loadTests ( this . loadedProjectRootPath ) ; } public async runTests ( tests , isComponentRun ) { await this . karmaRunner . runTests ( tests , isComponentRun ) ; this . logger . status ( this . karmaEventListener . testStatus ) ; } public async stopCurrentRun ( ) { if ( this . karmaRunner . isKarmaRunning ( ) ) { await this . testServer . stopAsync ( ) ; } } public dispose ( ) { if ( this . karmaRunner . isKarmaRunning ( ) ) { this . testServer . stop ( ) ; } } }