You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

chai-xml

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

chai-xml

Xml assertions for Chai

0.4.1
latest
Source
npm
Version published
Weekly downloads
17K
-12.99%
Maintainers
1
Weekly downloads
 
Created
Source

chai-xml

Xml assertions for Chai.

Install

In addition to the chai package, you need to install the plugin :

npm install chai-xml --save-dev

Example

var chai    = require('chai');
var expect  = require('chai').expect;
var chaiXml = require('chai-xml');

//loads the plugin
chai.use(chaiXml);

describe('assert some xml', function(){

    var someXml = '<root>\n\t<child name="foo" value="bar"></child>\n</root>';
    var otherXml = '<root><child value="bar" name="foo" /></root>';

    it("should be valid", function(){
        expect(someXml).xml.to.be.valid();
    });

    it("should be the same string as otherXml ", function(){
        expect(someXml).to.not.equal(otherXml);
    });
    it("should be the same XML as otherXml ", function(){
        expect(someXml).xml.to.equal(otherXml);
    });

    it("should be the same XML ignoring the whitespace at the begining and end of the text nodes", function () {
        var formattedXml = "<tag>\n\tContent\n</tag>";
        var unformattedXml = "<tag>Content</tag>";
        expect(formattedXml).xml.to.deep.equal(unformattedXml);
    });
});

Usage

  • XML must be a string
  • Add the property xml to your chain
  • The equal/eq/equals methods compare XML instead of the strings
  • The valid method check whether the XML is well-formed

Contributing

Any contribution is welcome! Please check the issues. Do some unit tests as far as possible.

Release History

  • 0.4.1 dependency update
  • 0.3.0 adding deep comparison. Thanks to PR #2
    • 0.3.1 change package.json keywords
    • 0.3.2 Add eslint, fix parsing error when invalid, add package-lock.json
  • 0.2.0 initial release. Support xml property, valid method and overwrite the equal/eq/equals methods

License

Copyright (c) 2014-2023 Bertrand Chevrier
Licensed under the MIT license.

Keywords

chai-plugin

FAQs

Package last updated on 19 Apr 2023

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