@@ -50,6 +50,9 @@ let mockedConsoleLogOriginal: Console["log"] | null = null;
5050 */
5151let mockedConsoleLogValues : string [ ] | null = null ;
5252
53+ // Get original CI environment variables
54+ const { CI , CIRCLECI , GITHUB_ACTION , BUILD_BUILDURI } = process . env ;
55+
5356// TODO: the following two functions are identical to the ones found in list.test.ts
5457// we are choosing to duplicate them for now, because with a shared helper function,
5558// jest overwrites console log output as the tests are run in parallel
@@ -369,6 +372,11 @@ describe("service:check", () => {
369372
370373 nock . disableNetConnect ( ) ;
371374
375+ delete process . env . CI ;
376+ delete process . env . CIRCLECI ;
377+ delete process . env . GITHUB_ACTION ;
378+ delete process . env . BUILD_BUILDURI ;
379+
372380 // Set the jest timeout to be longer than the default 5000ms to compensate for slow CI.
373381 jest . setTimeout ( 25000 ) ;
374382 } ) ;
@@ -382,6 +390,11 @@ describe("service:check", () => {
382390 // Clean up all network mocks and restore original functionality
383391 nock . cleanAll ( ) ;
384392 nock . enableNetConnect ( ) ;
393+
394+ process . env . CI = CI ;
395+ process . env . CIRCLECI = CIRCLECI ;
396+ process . env . GITHUB_ACTION = GITHUB_ACTION ;
397+ process . env . BUILD_BUILDURI = BUILD_BUILDURI ;
385398 } ) ;
386399
387400 // These are integration tests and not e2e tests because these don't actually hit the remote server.
@@ -406,6 +419,26 @@ describe("service:check", () => {
406419 expect ( uncaptureApplicationOutput ( ) ) . toMatchSnapshot ( ) ;
407420 } ) ;
408421
422+ it ( "compacts output in CI" , async ( ) => {
423+ captureApplicationOutput ( ) ;
424+ mockCompositionFailure ( ) ;
425+
426+ expect . assertions ( 2 ) ;
427+
428+ process . env . CI = "true" ;
429+
430+ await expect (
431+ ServiceCheck . run ( [
432+ ...cliKeyParameter ,
433+ "--serviceName=accounts" ,
434+ `--endpoint=${ localURL } /graphql`
435+ ] )
436+ ) . rejects . toThrow ( ) ;
437+
438+ // Inline snapshots don't work here due to https://github.com/facebook/jest/issues/6744.
439+ expect ( uncaptureApplicationOutput ( ) ) . toMatchSnapshot ( ) ;
440+ } ) ;
441+
409442 it ( "--markdown" , async ( ) => {
410443 captureApplicationOutput ( ) ;
411444 mockCompositionFailure ( ) ;
@@ -466,6 +499,26 @@ describe("service:check", () => {
466499 expect ( uncaptureApplicationOutput ( ) ) . toMatchSnapshot ( ) ;
467500 } ) ;
468501
502+ it ( "compacts output in CI" , async ( ) => {
503+ captureApplicationOutput ( ) ;
504+ mockCompositionSuccess ( ) ;
505+
506+ expect . assertions ( 2 ) ;
507+
508+ process . env . CI = "true" ;
509+
510+ await expect (
511+ ServiceCheck . run ( [
512+ ...cliKeyParameter ,
513+ "--serviceName=accounts" ,
514+ `--endpoint=${ localURL } /graphql`
515+ ] )
516+ ) . resolves . not . toThrow ( ) ;
517+
518+ // Inline snapshots don't work here due to https://github.com/facebook/jest/issues/6744.
519+ expect ( uncaptureApplicationOutput ( ) ) . toMatchSnapshot ( ) ;
520+ } ) ;
521+
469522 it ( "--markdown" , async ( ) => {
470523 captureApplicationOutput ( ) ;
471524 mockCompositionSuccess ( ) ;
0 commit comments