@@ -286,11 +286,13 @@ const _tests = [];
286286
287287return addManifest ( manifest , _tests )
288288 . then ( ( ) => {
289- _testsToMocha ( _tests ) ;
290- } ) . then ( ( ) => {
289+ return _testsToMocha ( _tests ) ;
290+ } ) . then ( result => {
291291 if ( options . earl . report ) {
292292 describe ( 'Writing EARL report to: ' + options . earl . filename , function ( ) {
293- it ( 'should print the earl report' , function ( ) {
293+ // print out EARL even if .only was used
294+ const _it = result . hadOnly ? it . only : it ;
295+ _it ( 'should print the earl report' , function ( ) {
294296 return options . writeFile (
295297 options . earl . filename , options . earl . report . reportJson ( ) ) ;
296298 } ) ;
@@ -300,6 +302,7 @@ return addManifest(manifest, _tests)
300302
301303// build mocha tests from local test structure
302304function _testsToMocha ( tests ) {
305+ let hadOnly = false ;
303306 tests . forEach ( suite => {
304307 if ( suite . skip ) {
305308 describe . skip ( suite . title ) ;
@@ -308,17 +311,22 @@ function _testsToMocha(tests) {
308311 describe ( suite . title , ( ) => {
309312 suite . tests . forEach ( test => {
310313 if ( test . only ) {
314+ hadOnly = true ;
311315 it . only ( test . title , test . f ) ;
312316 return ;
313317 }
314318 it ( test . title , test . f ) ;
315319 } ) ;
316- _testsToMocha ( suite . suites ) ;
320+ const { hadOnly : _hadOnly } = _testsToMocha ( suite . suites ) ;
321+ hadOnly = hadOnly || _hadOnly ;
317322 } ) ;
318323 suite . imports . forEach ( f => {
319324 options . import ( f ) ;
320325 } ) ;
321326 } ) ;
327+ return {
328+ hadOnly
329+ } ;
322330}
323331
324332} ) ;
0 commit comments