Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests(inline-fs): fix error in Node 20 #16262

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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