Skip to content

Commit 0192ee6

Browse files
authored
tests(inline-fs): fix error in Node 20 (#16262)
1 parent b64b353 commit 0192ee6

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

build/test/plugins/inline-fs-test.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -342,17 +342,18 @@ describeSkipOnWindows('inline-fs', () => {
342342
it('warns and skips when missing encoding', async () => {
343343
const content = `const myTextContent = fs.readFileSync('${tmpPath}');`;
344344
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,
355355
});
356+
expect(result.warnings[0].text).toMatch(/^fs\.readFileSync\(\) must have two arguments/);
356357
});
357358

358359
it('warns and skips on unsupported encoding', async () => {

0 commit comments

Comments
 (0)