@@ -14,16 +14,13 @@ jest.unmock('@adobe/aio-lib-core-config')
1414
1515const execa = require ( 'execa' )
1616const chalk = require ( 'chalk' )
17- const { stdout } = require ( 'stdout-stderr' )
1817const { context } = require ( '@adobe/aio-lib-ims' )
1918const fs = require ( 'fs' )
2019
2120const CONTEXT_NAME = 'aio-cli-plugin-cloudmanager-e2e'
2221
2322const CONTEXT_ARGS = [ '--imsContextName' , CONTEXT_NAME ]
2423
25- stdout . print = true
26-
2724beforeEach ( async ( ) => {
2825 await clearAuthContext ( )
2926} )
@@ -32,6 +29,17 @@ const clearAuthContext = async () => {
3229 await context . set ( CONTEXT_NAME , { } )
3330}
3431
32+ const exec = ( cmd , args ) => {
33+ try {
34+ const result = execa . sync ( cmd , args )
35+ console . log ( 'result of %s %s: %s' , cmd , args , result . stdout )
36+ return result
37+ } catch ( e ) {
38+ console . error ( 'result of %s %s: (stdout): %s; (stderr): %s' , cmd , args , e . stdout , e . stderr )
39+ throw e
40+ }
41+ }
42+
3543const bootstrapAuthContext = async ( ) => {
3644 const contextObj = {
3745 client_id : process . env . E2E_CLIENT_ID ,
@@ -53,7 +61,7 @@ test('plugin-cloudmanager help test', async () => {
5361 console . log ( chalk . blue ( `> e2e tests for ${ chalk . bold ( name ) } ` ) )
5462
5563 console . log ( chalk . dim ( ' - plugin-cloudmanager help ..' ) )
56- expect ( ( ) => { execa . sync ( './bin/run' , [ '--help' ] , { stderr : 'inherit' } ) } ) . not . toThrow ( )
64+ expect ( ( ) => { exec ( './bin/run' , [ '--help' ] ) } ) . not . toThrow ( )
5765
5866 console . log ( chalk . green ( ` - done for ${ chalk . bold ( name ) } ` ) )
5967} )
@@ -67,7 +75,7 @@ test('plugin-cloudmanager list-programs', async () => {
6775 console . log ( chalk . dim ( ' - plugin-cloudmanager list-programs ..' ) )
6876
6977 let result
70- expect ( ( ) => { result = execa . sync ( './bin/run' , [ 'cloudmanager:list-programs' , ...CONTEXT_ARGS , '--json' ] , { stderr : 'inherit' } ) } ) . not . toThrow ( )
78+ expect ( ( ) => { result = exec ( './bin/run' , [ 'cloudmanager:list-programs' , ...CONTEXT_ARGS , '--json' ] ) } ) . not . toThrow ( )
7179 const parsed = JSON . parse ( result . stdout )
7280 expect ( parsed ) . toSatisfy ( arr => arr . length > 0 )
7381
0 commit comments