File tree Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Expand file tree Collapse file tree 3 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -101,7 +101,15 @@ Xvfb.prototype = {
101101  } , 
102102
103103  _restoreDisplayEnvVariable : function  ( )  { 
104-     process . env . DISPLAY  =  this . _oldDisplay 
104+     // https://github.com/cypress-io/xvfb/issues/1 
105+     // only reset truthy backed' up values 
106+     if  ( this . _oldDisplay )  { 
107+       process . env . DISPLAY  =  this . _oldDisplay 
108+     }  else  { 
109+       // else delete the values to get back 
110+       // to undefined 
111+       delete  process . env . DISPLAY 
112+     } 
105113  } , 
106114
107115  _spawnProcess : function  ( lockFileExists ,  onAsyncSpawnError )  { 
Original file line number Diff line number Diff line change 1313  "dependencies" : {},
1414  "license" : " MIT" 
1515  "scripts" : {
16-     "test" : " standard --fix --verbose *.js" 
16+     "test" : " standard --fix --verbose *.js && mocha " 
1717    "semantic-release" : " semantic-release pre && npm publish --access public && semantic-release post" 
1818    "commit" : " commit-wizard" 
1919  },
2020  "devDependencies" : {
21+     "chai" : " ^4.1.2" 
2122    "condition-circle" : " ^1.5.0" 
23+     "mocha" : " ^3.5.0" 
2224    "pre-git" : " ^3.15.0" 
2325    "semantic-release" : " ^6.3.6" 
2426    "simple-commit-message" : " ^3.0.2" 
Original file line number Diff line number Diff line change 1+ const  {  expect }  =  require ( 'chai' ) 
2+ 
3+ const  Xvfb  =  require ( '../' ) 
4+ 
5+ describe ( 'xvfb' ,  function ( ) { 
6+   beforeEach ( function ( ) { 
7+     this . xvfb  =  new  Xvfb ( ) 
8+   } ) 
9+ 
10+   context ( 'issue: #1' ,  function ( ) { 
11+     it ( 'issue #1: does not mutate process.env.DISPLAY' ,  function ( ) { 
12+       delete  process . env . DISPLAY 
13+ 
14+       expect ( process . env . DISPLAY ) . to . be . undefined 
15+ 
16+       this . xvfb . _setDisplayEnvVariable ( ) 
17+       this . xvfb . _restoreDisplayEnvVariable ( ) 
18+ 
19+       expect ( process . env . DISPLAY ) . to . be . undefined 
20+     } ) 
21+   } ) 
22+ } ) 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments