Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-xml-matcher

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-xml-matcher

Jest matcher to validate xml equality

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12K
decreased by-6.56%
Maintainers
1
Weekly downloads
 
Created
Source

jest-xml-matcher

Custom Jest matcher which can be used to find differences between XML structures

Installation

It can be installed using yarn

yarn add -D jest-xml-matcher

Or using npm

npm install --save-dev jest-xml-matcher

Usage with JS

Simplest way to use matcher with Jest is to modify setupTestFrameworkScriptFile configuration part.

To do this, include following part in package.json:

"jest": {
  "setupTestFrameworkScriptFile": "./node_modules/jest-xml-matcher/index.js",
  ...
}

Usage with TS (or JS)

It possible to use test entry file or spec file and include module there (as in setupTests.js while using CRA):

require('jest-xml-matcher')
// or
import 'jest-xml-matcher'

By adding lines mentioned above, expect is being extended with toEqualXML check. See examples for more explanation.

Examples

Assuming you have following XML structures:

const actualXML = `
  <parent>
    <child attr="test">
      <anotherInside>That's changing</anotherInside>
    </child>
  </parent>
`

const expectedXML = `
  <parenting>
    <child attr="tested">
      <anotherInside>What a pity :(</anotherInside>
    </child>
  </parenting>
`

In test file you can write

expect(actualXML).toEqualXML(expectedXML)

Which should result in:

example

Keywords

FAQs

Package last updated on 03 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc