fix(deps): update dependency fast-xml-parser to v5 (#4358)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
Co-authored-by: cte <cestreich@gmail.com>
This commit is contained in:
renovate[bot] 2025-06-10 13:51:12 -07:00 committed by GitHub
parent cf7c4a13a0
commit 639cace3f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 41 additions and 24 deletions

17
pnpm-lock.yaml generated
View file

@ -643,8 +643,8 @@ importers:
specifier: ^3.1.3
version: 3.1.3
fast-xml-parser:
specifier: ^4.5.1
version: 4.5.3
specifier: ^5.0.0
version: 5.2.3
fastest-levenshtein:
specifier: ^1.0.16
version: 1.0.16
@ -6401,8 +6401,8 @@ packages:
resolution: {integrity: sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==}
hasBin: true
fast-xml-parser@4.5.3:
resolution: {integrity: sha512-RKihhV+SHsIUGXObeVy9AXiBbFwkVk7Syp8XgwN5U3JV416+Gwp/GO9i0JYKmikykgz/UHRrrV4ROuZEo/T0ig==}
fast-xml-parser@5.2.3:
resolution: {integrity: sha512-OdCYfRqfpuLUFonTNjvd30rCBZUneHpSQkCqfaeWQ9qrKcl6XlWeDBNVwGb+INAIxRshuN2jF+BE0L6gbBO2mw==}
hasBin: true
fastest-levenshtein@1.0.16:
@ -9646,6 +9646,9 @@ packages:
strnum@1.1.2:
resolution: {integrity: sha512-vrN+B7DBIoTTZjnPNewwhx6cBA/H+IS7rfW68n7XxC1y7uoiGQBxaKzqucGUgavX15dJgiGztLJ8vxuEzwqBdA==}
strnum@2.1.1:
resolution: {integrity: sha512-7ZvoFTiCnGxBtDqJ//Cu6fWtZtc7Y3x+QOirG15wztbdngGSkht27o2pyGWrVy0b4WAy3jbKmnoK6g5VlVNUUw==}
strong-type@0.1.6:
resolution: {integrity: sha512-eJe5caH6Pi5oMMeQtIoBPpvNu/s4jiyb63u5tkHNnQXomK+puyQ5i+Z5iTLBr/xUz/pIcps0NSfzzFI34+gAXg==}
engines: {node: '>=12.0.0'}
@ -16899,9 +16902,9 @@ snapshots:
dependencies:
strnum: 1.1.2
fast-xml-parser@4.5.3:
fast-xml-parser@5.2.3:
dependencies:
strnum: 1.1.2
strnum: 2.1.1
fastest-levenshtein@1.0.16: {}
@ -20979,6 +20982,8 @@ snapshots:
strnum@1.1.2: {}
strnum@2.1.1: {}
strong-type@0.1.6: {}
strong-type@1.1.0: {}

View file

@ -378,7 +378,7 @@
"diff": "^5.2.0",
"diff-match-patch": "^1.0.5",
"fast-deep-equal": "^3.1.3",
"fast-xml-parser": "^4.5.1",
"fast-xml-parser": "^5.0.0",
"fastest-levenshtein": "^1.0.16",
"fzf": "^0.5.2",
"get-folder-size": "^5.0.0",

View file

@ -117,35 +117,47 @@ describe("parseXml", () => {
describe("error handling", () => {
it("wraps parser errors with a descriptive message", () => {
// Use jest.spyOn to mock the XMLParser implementation
// Create a mock implementation that throws an error
const mockParseFn = jest.fn().mockImplementation(() => {
throw new Error("Simulated parsing error")
})
// Create a mock parser instance
const mockParserInstance = {
parse: mockParseFn,
}
// Spy on the XMLParser constructor to return our mock
const parserSpy = jest
.spyOn(require("fast-xml-parser"), "XMLParser")
.mockImplementation(() => mockParserInstance)
// Create a mock constructor function
const MockXMLParser = jest.fn().mockImplementation(() => mockParserInstance)
// Test that our function wraps the error appropriately
expect(() => parseXml("<root></root>")).toThrow("Failed to parse XML: Simulated parsing error")
// Save the original XMLParser
const { XMLParser } = jest.requireActual("fast-xml-parser")
// Verify the parser was called with the expected options
expect(parserSpy).toHaveBeenCalledWith({
ignoreAttributes: false,
attributeNamePrefix: "@_",
parseAttributeValue: false,
parseTagValue: false,
trimValues: true,
stopNodes: [],
// Replace the XMLParser with our mock
jest.doMock("fast-xml-parser", () => ({
XMLParser: MockXMLParser,
}))
// Import the module with our mocked dependency
jest.isolateModules(() => {
const { parseXml } = require("../xml")
// Test that our function wraps the error appropriately
expect(() => parseXml("<root></root>")).toThrow("Failed to parse XML: Simulated parsing error")
// Verify the parser was called with the expected options
expect(MockXMLParser).toHaveBeenCalledWith({
ignoreAttributes: false,
attributeNamePrefix: "@_",
parseAttributeValue: false,
parseTagValue: false,
trimValues: true,
stopNodes: [],
})
})
// Cleanup
parserSpy.mockRestore()
// Restore the original module
jest.dontMock("fast-xml-parser")
})
})
})