@@ -12,9 +12,11 @@ jest.mock('../src/validateInput');
1212describe ( 'validateEnvVars' , ( ) => {
1313 let processExitSpy : jest . SpyInstance ;
1414 let consoleErrorSpy : jest . SpyInstance ;
15+ let consoleLogSpy : jest . SpyInstance ;
1516
1617 beforeEach ( ( ) => {
1718 consoleErrorSpy = jest . spyOn ( console , 'error' ) . mockImplementation ( ) ;
19+ consoleLogSpy = jest . spyOn ( console , 'log' ) . mockImplementation ( ) ;
1820 processExitSpy = jest . spyOn ( process , 'exit' ) . mockImplementation ( ) ;
1921 } ) ;
2022
@@ -145,4 +147,26 @@ describe('validateEnvVars', () => {
145147 validateEnvVars ( { schema, envPath } ) ;
146148 } ) . not . toThrow ( ) ;
147149 } ) ;
150+
151+ it ( 'descriptions are logged on console warning' , ( ) => {
152+ const schema = z . object ( {
153+ OPTIONAL_1 : z
154+ . string ( { description : 'This is an optional variable' } )
155+ . optional ( ) ,
156+ EXPECTED_2 : z . string ( ) ,
157+ } ) ;
158+ const envPath = './__tests__/.env.test' ;
159+
160+ validateEnvVars ( { schema, envPath } ) ;
161+
162+ expect ( consoleLogSpy ) . toHaveBeenCalledTimes ( 3 ) ;
163+ expect ( consoleLogSpy ) . toHaveBeenNthCalledWith (
164+ 1 ,
165+ expect . stringContaining ( 'This is an optional variable' )
166+ ) ;
167+ expect ( consoleLogSpy ) . toHaveBeenNthCalledWith (
168+ 2 ,
169+ expect . not . stringContaining ( 'This is an optional variable' )
170+ ) ;
171+ } ) ;
148172} ) ;
0 commit comments