@@ -6,7 +6,7 @@ const originalConsoleWarn = console.warn
6
6
// Make this a module to fix TypeScript error
7
7
export { }
8
8
9
- describe ( 'Node.js 18 Deprecation Warning' , ( ) => {
9
+ describe ( 'Node.js <= 18 Deprecation Warning' , ( ) => {
10
10
let mockConsoleWarn : jest . SpyInstance
11
11
12
12
beforeEach ( ( ) => {
@@ -42,7 +42,7 @@ describe('Node.js 18 Deprecation Warning', () => {
42
42
require ( '../../src/index' )
43
43
44
44
expect ( mockConsoleWarn ) . toHaveBeenCalledWith (
45
- expect . stringContaining ( '⚠️ Node.js 18 is deprecated' )
45
+ expect . stringContaining ( '⚠️ Node.js 18 and below are deprecated' )
46
46
)
47
47
expect ( mockConsoleWarn ) . toHaveBeenCalledWith (
48
48
expect . stringContaining ( 'Please upgrade to Node.js 20 or later' )
@@ -100,7 +100,7 @@ describe('Node.js 18 Deprecation Warning', () => {
100
100
expect ( mockConsoleWarn ) . not . toHaveBeenCalled ( )
101
101
} )
102
102
103
- test ( 'should NOT show warning for Node.js 16.20.0' , ( ) => {
103
+ test ( 'should show warning for Node.js 16.20.0' , ( ) => {
104
104
delete ( global as any ) . window
105
105
global . process = {
106
106
...originalProcess ,
@@ -109,7 +109,31 @@ describe('Node.js 18 Deprecation Warning', () => {
109
109
110
110
require ( '../../src/index' )
111
111
112
- expect ( mockConsoleWarn ) . not . toHaveBeenCalled ( )
112
+ expect ( mockConsoleWarn ) . toHaveBeenCalled ( )
113
+ } )
114
+
115
+ test ( 'should show warning for Node.js 17.9.1' , ( ) => {
116
+ delete ( global as any ) . window
117
+ global . process = {
118
+ ...originalProcess ,
119
+ version : 'v17.9.1' ,
120
+ } as NodeJS . Process
121
+
122
+ require ( '../../src/index' )
123
+
124
+ expect ( mockConsoleWarn ) . toHaveBeenCalled ( )
125
+ } )
126
+
127
+ test ( 'should show warning for Node.js 14.21.3' , ( ) => {
128
+ delete ( global as any ) . window
129
+ global . process = {
130
+ ...originalProcess ,
131
+ version : 'v14.21.3' ,
132
+ } as NodeJS . Process
133
+
134
+ require ( '../../src/index' )
135
+
136
+ expect ( mockConsoleWarn ) . toHaveBeenCalled ( )
113
137
} )
114
138
115
139
test ( 'should NOT show warning when window is defined (browser environment)' , ( ) => {
@@ -133,8 +157,7 @@ describe('Node.js 18 Deprecation Warning', () => {
133
157
const shouldShow =
134
158
typeof mockWindow === 'undefined' &&
135
159
typeof mockProcess !== 'undefined' &&
136
- ( mockProcess as any ) ?. version !== undefined &&
137
- / ^ v 1 8 \. / . test ( ( mockProcess as any ) ?. version || '' )
160
+ ( mockProcess as any ) ?. version !== undefined
138
161
139
162
expect ( shouldShow ) . toBe ( false )
140
163
expect ( mockConsoleWarn ) . not . toHaveBeenCalled ( )
@@ -152,7 +175,7 @@ describe('Node.js 18 Deprecation Warning', () => {
152
175
expect ( mockConsoleWarn ) . not . toHaveBeenCalled ( )
153
176
} )
154
177
155
- test ( 'should NOT show warning for version string "18" without "v" prefix' , ( ) => {
178
+ test ( 'should NOT show warning for version string "18" without "v" prefix (malformed) ' , ( ) => {
156
179
delete ( global as any ) . window
157
180
global . process = {
158
181
...originalProcess ,
@@ -164,7 +187,7 @@ describe('Node.js 18 Deprecation Warning', () => {
164
187
expect ( mockConsoleWarn ) . not . toHaveBeenCalled ( )
165
188
} )
166
189
167
- test ( 'should NOT show warning for version containing "18" but not starting with "v18." ' , ( ) => {
190
+ test ( 'should show warning for version v1.18.0 (major version 1) ' , ( ) => {
168
191
delete ( global as any ) . window
169
192
global . process = {
170
193
...originalProcess ,
@@ -173,7 +196,7 @@ describe('Node.js 18 Deprecation Warning', () => {
173
196
174
197
require ( '../../src/index' )
175
198
176
- expect ( mockConsoleWarn ) . not . toHaveBeenCalled ( )
199
+ expect ( mockConsoleWarn ) . toHaveBeenCalled ( )
177
200
} )
178
201
} )
179
202
@@ -207,7 +230,7 @@ describe('Node.js 18 Deprecation Warning', () => {
207
230
expect ( mockConsoleWarn ) . toHaveBeenCalledTimes ( 1 )
208
231
209
232
const warningMessage = mockConsoleWarn . mock . calls [ 0 ] [ 0 ]
210
- expect ( warningMessage ) . toContain ( '⚠️ Node.js 18 is deprecated' )
233
+ expect ( warningMessage ) . toContain ( '⚠️ Node.js 18 and below are deprecated' )
211
234
expect ( warningMessage ) . toContain ( 'will no longer be supported in future versions' )
212
235
expect ( warningMessage ) . toContain ( '@supabase/supabase-js' )
213
236
expect ( warningMessage ) . toContain ( 'Please upgrade to Node.js 20 or later' )
0 commit comments