Skip to content

Commit

Permalink
tests(inline-fs): fix error in Node 20 (#16262)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine authored Nov 26, 2024
1 parent b64b353 commit 0192ee6
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions build/test/plugins/inline-fs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit 0192ee6

Please sign in to comment.