@@ -148,24 +148,15 @@ export default class Test extends SfCommand<RunCommandResult> {
148148
149149 if ( 'summary' in result ) {
150150 const testReporter = new TestReporter ( new Ux ( { jsonEnabled : this . jsonEnabled ( ) } ) , conn , this . config . bin ) ;
151-
152- return testReporter . report ( result , {
153- wait : flags . wait ,
154- 'output-dir' : flags [ 'output-dir' ] ,
155- 'result-format' : flags [ 'result-format' ] ,
156- 'detailed-coverage' : flags [ 'detailed-coverage' ] ,
157- synchronous : flags . synchronous ,
158- json : flags . json ,
159- codeCoverage : flags [ 'code-coverage' ] ,
160- } ) ;
151+ return testReporter . report ( result , flags ) ;
161152 } else {
162153 // async test run
163154 this . log ( messages . getMessage ( 'runTestReportCommand' , [ this . config . bin , result . testRunId , conn . getUsername ( ) ] ) ) ;
164155 return result ;
165156 }
166157 }
167158
168- // eslint-disable-next-line class-methods-use-this,complexity
159+ // eslint-disable-next-line class-methods-use-this
169160 public async validateFlags (
170161 codeCoverage ?: boolean ,
171162 resultFormatFlag ?: string ,
@@ -187,16 +178,13 @@ export default class Test extends SfCommand<RunCommandResult> {
187178 return Promise . reject ( new Error ( messages . getMessage ( 'testLevelErr' ) ) ) ;
188179 }
189180
190- let test : TestLevel ;
191181 if ( testLevel ) {
192- test = testLevel ;
193- } else if ( classNames || suiteNames || tests ) {
194- test = TestLevel . RunSpecifiedTests ;
195- } else {
196- test = TestLevel . RunLocalTests ;
182+ return testLevel ;
197183 }
198-
199- return test ;
184+ if ( classNames || suiteNames || tests ) {
185+ return TestLevel . RunSpecifiedTests ;
186+ }
187+ return TestLevel . RunLocalTests ;
200188 }
201189
202190 private async runTest (
@@ -212,11 +200,11 @@ export default class Test extends SfCommand<RunCommandResult> {
212200 ...( await testService . buildSyncPayload ( testLevel , flags . tests , flags [ 'class-names' ] ) ) ,
213201 skipCodeCoverage : ! flags [ 'code-coverage' ] ,
214202 } ;
215- return ( await testService . runTestSynchronous (
203+ return testService . runTestSynchronous (
216204 payload ,
217205 flags [ 'code-coverage' ] ,
218206 this . cancellationTokenSource . token
219- ) ) as TestResult ;
207+ ) as Promise < TestResult > ;
220208 }
221209
222210 private async runTestAsynchronous (
@@ -239,34 +227,12 @@ export default class Test extends SfCommand<RunCommandResult> {
239227 } ;
240228
241229 // cast as TestRunIdResult because we're building an async payload which will return an async result
242- return ( await testService . runTestAsynchronous (
230+ return testService . runTestAsynchronous (
243231 payload ,
244232 flags [ 'code-coverage' ] ,
245- shouldImmediatelyReturn ( flags . synchronous , flags [ 'result-format' ] , flags . json , flags . wait ) ,
233+ flags . wait && flags . wait . minutes > 0 ? false : ! ( flags . synchronous && ! this . jsonEnabled ( ) ) ,
246234 undefined ,
247235 this . cancellationTokenSource . token
248- ) ) as TestRunIdResult ;
236+ ) as Promise < TestRunIdResult > ;
249237 }
250238}
251- /**
252- * Handles special exceptions where we don't want to return early
253- * with the testRunId.
254- **/
255- const shouldImmediatelyReturn = (
256- synchronous ?: boolean ,
257- resultFormatFlag ?: string ,
258- json ?: boolean ,
259- wait ?: Duration
260- ) : boolean => {
261- if ( resultFormatFlag !== undefined ) {
262- return false ;
263- }
264-
265- // when the user has explictly asked to wait for results, but didn't give a format
266- if ( wait ) {
267- return false ;
268- }
269-
270- // historical expectation to wait for results from a synchronous test run
271- return ! ( synchronous && ! json ) ;
272- } ;
0 commit comments