@@ -16,7 +16,14 @@ jest.mock('@oclif/core', () => {
1616 return {
1717 ...jest . requireActual ( '@oclif/core' ) ,
1818 Config : {
19- load : ( ) => ( { } )
19+ load : ( ) => ( {
20+ pjson : {
21+ engines : {
22+ node : '>=18 <23'
23+ }
24+ } ,
25+ options : { }
26+ } )
2027 } ,
2128 Command : jest . fn ( ) ,
2229 run : async function ( cmd ) {
@@ -45,3 +52,47 @@ describe('run command', () => {
4552 process . argv = temp
4653 } )
4754} )
55+
56+ describe ( 'Node.js version check' , ( ) => {
57+ const originalVersion = process . version
58+ let logSpy
59+
60+ beforeEach ( ( ) => {
61+ logSpy = jest . spyOn ( console , 'log' ) . mockImplementation ( )
62+ } )
63+
64+ afterEach ( ( ) => {
65+ jest . restoreAllMocks ( )
66+ Object . defineProperty ( process , 'version' , {
67+ value : originalVersion
68+ } )
69+ } )
70+
71+ test ( 'should not show warning for supported Node.js version' , async ( ) => {
72+ Object . defineProperty ( process , 'version' , {
73+ value : 'v22.14.0'
74+ } )
75+
76+ const AIOCommand = require ( '../src/index' )
77+ await AIOCommand . run ( [ '--version' ] )
78+
79+ // Check warning is not displayed
80+ expect ( logSpy ) . not . toHaveBeenCalledWith (
81+ expect . stringContaining ( 'Warning: Node.js version' )
82+ )
83+ } )
84+
85+ test ( 'should show warning for unsupported Node.js version' , async ( ) => {
86+ Object . defineProperty ( process , 'version' , {
87+ value : 'v23.0.0'
88+ } )
89+
90+ const AIOCommand = require ( '../src/index' )
91+ await AIOCommand . run ( [ '--version' ] )
92+
93+ // Check warning is displayed
94+ expect ( logSpy ) . toHaveBeenCalledWith (
95+ expect . stringContaining ( 'Warning: Node.js version v23.0.0 is not supported' )
96+ )
97+ } )
98+ } )
0 commit comments