11let oldIsTTY ;
2+ let oldTERM ;
23
34beforeEach ( ( ) => {
45 oldIsTTY = process . stdout . isTTY ;
6+ oldTERM = process . env . TERM ;
57} ) ;
68
79afterEach ( ( ) => {
810 process . stdout . isTTY = oldIsTTY ;
11+ process . env . TERM = oldTERM ;
912 jest . resetModules ( ) ;
1013} ) ;
1114
1215it ( 'Returns true when running on interactive environment' , ( ) => {
1316 jest . doMock ( 'is-ci' , ( ) => false ) ;
1417 process . stdout . isTTY = true ;
18+ process . env . TERM = 'xterm-256color' ;
1519
1620 const isInteractive = require ( '../is_interative' ) . default ;
1721 expect ( isInteractive ) . toBe ( true ) ;
@@ -24,20 +28,31 @@ it('Returns false when running on a non-interactive environment', () => {
2428 // Test with is-ci being true and isTTY false
2529 jest . doMock ( 'is-ci' , ( ) => true ) ;
2630 process . stdout . isTTY = false ;
31+ process . env . TERM = 'xterm-256color' ;
2732 isInteractive = require ( '../is_interative' ) . default ;
2833 expect ( isInteractive ) . toBe ( expectedResult ) ;
2934
3035 // Test with is-ci being false and isTTY false
3136 jest . resetModules ( ) ;
3237 jest . doMock ( 'is-ci' , ( ) => false ) ;
3338 process . stdout . isTTY = false ;
39+ process . env . TERM = 'xterm-256color' ;
3440 isInteractive = require ( '../is_interative' ) . default ;
3541 expect ( isInteractive ) . toBe ( expectedResult ) ;
3642
3743 // Test with is-ci being true and isTTY true
3844 jest . resetModules ( ) ;
3945 jest . doMock ( 'is-ci' , ( ) => true ) ;
4046 process . stdout . isTTY = true ;
47+ process . env . TERM = 'xterm-256color' ;
48+ isInteractive = require ( '../is_interative' ) . default ;
49+ expect ( isInteractive ) . toBe ( expectedResult ) ;
50+
51+ // Test with dumb terminal
52+ jest . resetModules ( ) ;
53+ jest . doMock ( 'is-ci' , ( ) => false ) ;
54+ process . stdout . isTTY = false ;
55+ process . env . TERM = 'dumb' ;
4156 isInteractive = require ( '../is_interative' ) . default ;
4257 expect ( isInteractive ) . toBe ( expectedResult ) ;
4358} ) ;
0 commit comments