File tree Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Expand file tree Collapse file tree 1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -342,17 +342,18 @@ describeSkipOnWindows('inline-fs', () => {
342
342
it ( 'warns and skips when missing encoding' , async ( ) => {
343
343
const content = `const myTextContent = fs.readFileSync('${ tmpPath } ');` ;
344
344
const result = await inlineFs ( content , filepath ) ;
345
- expect ( result ) . toEqual ( {
346
- code : null ,
347
- warnings : [ {
348
- text : 'fs.readFileSync() must have two arguments' ,
349
- location : {
350
- file : filepath ,
351
- line : 1 ,
352
- column : 22 ,
353
- } ,
354
- } ] ,
345
+
346
+ // These expectations are deconstructed because the warning text can have slight
347
+ // variations depending on the node version (18 vs 20).
348
+ // TODO: Use a simpler expectation when support for Node 18 is dropped.
349
+ expect ( result . code ) . toBeNull ( ) ;
350
+ expect ( result . warnings ) . toHaveLength ( 1 ) ;
351
+ expect ( result . warnings [ 0 ] . location ) . toEqual ( {
352
+ file : filepath ,
353
+ line : 1 ,
354
+ column : 22 ,
355
355
} ) ;
356
+ expect ( result . warnings [ 0 ] . text ) . toMatch ( / ^ f s \. r e a d F i l e S y n c \( \) m u s t h a v e t w o a r g u m e n t s / ) ;
356
357
} ) ;
357
358
358
359
it ( 'warns and skips on unsupported encoding' , async ( ) => {
You can’t perform that action at this time.
0 commit comments