diff --git a/build/test/plugins/inline-fs-test.js b/build/test/plugins/inline-fs-test.js index 8637ccc41162..7b7ac01f7a79 100644 --- a/build/test/plugins/inline-fs-test.js +++ b/build/test/plugins/inline-fs-test.js @@ -342,17 +342,18 @@ describeSkipOnWindows('inline-fs', () => { it('warns and skips when missing encoding', async () => { const content = `const myTextContent = fs.readFileSync('${tmpPath}');`; const result = await inlineFs(content, filepath); - expect(result).toEqual({ - code: null, - warnings: [{ - text: 'fs.readFileSync() must have two arguments', - location: { - file: filepath, - line: 1, - column: 22, - }, - }], + + // These expectations are deconstructed because the warning text can have slight + // variations depending on the node version (18 vs 20). + // TODO: Use a simpler expectation when support for Node 18 is dropped. + expect(result.code).toBeNull(); + expect(result.warnings).toHaveLength(1); + expect(result.warnings[0].location).toEqual({ + file: filepath, + line: 1, + column: 22, }); + expect(result.warnings[0].text).toMatch(/^fs\.readFileSync\(\) must have two arguments/); }); it('warns and skips on unsupported encoding', async () => {