{"id":27075903,"url":"https://github.com/mrbenhowl/messagecheckr","last_synced_at":"2026-05-07T18:39:47.668Z","repository":{"id":57295229,"uuid":"48424827","full_name":"mrbenhowl/messageCheckr","owner":"mrbenhowl","description":"Verifies SOAP and Java Message Service (JMS) messages and position delimited messages using Node.js","archived":false,"fork":false,"pushed_at":"2018-03-09T12:19:27.000Z","size":185,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T01:24:53.031Z","etag":null,"topics":["jms","nodejs","npm","soap","test","verification","xml"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrbenhowl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-22T10:07:06.000Z","updated_at":"2018-12-19T02:51:43.000Z","dependencies_parsed_at":"2022-08-30T22:30:46.518Z","dependency_job_id":null,"html_url":"https://github.com/mrbenhowl/messageCheckr","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrbenhowl%2FmessageCheckr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrbenhowl%2FmessageCheckr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrbenhowl%2FmessageCheckr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrbenhowl%2FmessageCheckr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrbenhowl","download_url":"https://codeload.github.com/mrbenhowl/messageCheckr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247416453,"owners_count":20935474,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jms","nodejs","npm","soap","test","verification","xml"],"created_at":"2025-04-06T00:18:24.338Z","updated_at":"2026-05-07T18:39:47.634Z","avatar_url":"https://github.com/mrbenhowl.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"messageCheckr [![Build Status](https://travis-ci.org/mrbenhowl/messageCheckr.svg)](https://travis-ci.org/mrbenhowl/messageCheckr)\n=============\n\nmessageChecker verifies SOAP and Java Message Service (JMS) messages and position delimited messages.\n\nContents\n--------\n* [Compatibility](#compatibility)\n* [Getting Started](#getting-started)\n* [Usage](#usage)\n  * [JMS messages](#jms-messages)\n  * [SOAP messages](#soap-messages)\n  * [Position delimited messages](#position-delimited-messages)\n* [expectedMessage types for SOAP and JMS](#expectedmessage-types-for-soap-and-jms)\n* [Operators](#operators)\n* [Date Format (dateFormat)](#date-format-dateformat)\n* [For Contributors](#for-contributors)\n\nCompatibility\n------------\n\nWorks with Node.js v4.* and higher\n\nGetting Started\n---------------\n\n`npm install messagecheckr` to install from the [NPM registry](https://www.npmjs.com/package/messagecheckr).\n\nUsage\n-----\n\n`var messageCheckr = require('messagecheckr');`\n\n###JMS messages\nLet's say we have the following JMS message\n\n    \u003c?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?\u003e\n     \u003ctestRootElement xmlns=\"http://www.testing.com/integration/event\"\u003e\n       \u003celementOne\u003ehello\u003c/elementOne\u003e\n       \u003canotherElement\u003e\n        \u003celementTwo\u003e123\u003c/elementTwo\u003e\n       \u003c/anotherElement\u003e\n    \u003c/testRootElement\u003e\n\nand we want to check the following:\n\n* `\u003ctestRootElement\u003e` has the attribute `xmlns` with the value `http://www.testing.com/integration/event`\n* `\u003celementOne\u003e` has the value `hello`\n* `\u003celementTwo\u003e` has an integer as a value\n\nFirst create the expected message as follows:\n\n    var expectedMessage = [\n        {path: 'testRootElement.testRootElement', attribute: 'xmlns', equals: 'http://www.testing.com/integration/event'},\n        {path: 'testRootElement.elementOne', equals: 'hello'},\n        {path: 'testRootElement.anotherElement.elementTwo', equals: '{integer}'},\n    ];\n\nTo check the above message we need to make a call to messageCheckr as follows:\n\n    var result = messageCheckr({\n      type: 'jms',\n      actualMsg: actualMessage,\n      expectedMsg: expectedMessage,\n      expectedRootElement: 'testRootElement'\n    });\n    // actualMessage is a string of the message you want to check.\n\nmessageCheckr returns an object with the attribute `allChecksPassed` which will be true if all checks (those in `expectedMessage`) have passed otherwise false, thus allowing you to do an assertion like the following:\n\n    assert.equal(result.allChecksPassed, true);\n    // this is using chai.js, any assertion library can be used.\n\nThe object returned by messageCheckr also has an attribute called `checks`. In the case above the `checks` object will be empty because there are no failing checks. By default only failing checks are present. If you wish to see all checks provide the parameter `verbose` to messageCheckr(). If `verbose` was supplied (and set to true) checks would contain the following:\n\n    [\n        {\n            \"pass\":true,\n            \"target\":\"testRootElement\",\n            \"actual\":\"testRootElement\",\n            \"expected\":\"testRootElement\",\n            \"description\":\"Check actual root element testRootElement is equal to expected root element testRootElement\"\n        },\n        {\n            \"pass\":true,\n            \"target\":{\"path\":\"testRootElement\",\"attribute\":\"xmlns\"},\n            \"actual\":\"http://www.testing.com/integration/event\",\n            \"expected\":\"http://www.testing.com/integration/event\",\n            \"description\":\"Check actual value http://www.testing.com/integration/event is equal to http://www.testing.com/integration/event\"},\n        {\n            \"pass\":true,\n            \"target\":{\"path\":\"testRootElement.elementOne\"},\n            \"actual\":\"hello\",\n            \"expected\":\"hello\",\n            \"description\":\"Check actual value hello is equal to hello\"},\n        {\n            \"pass\":true,\n            \"target\":{\"path\":\"testRootElement.anotherElement.elementTwo\"},\n            \"actual\":\"123\",\n            \"expected\":\"{integer}\",\n            \"description\":\"Check actual value 123 is an integer\"\n        }\n    ]\n\nIn projects where I use messageCheckr I assert its result as follows, which will print out failing checks if there are any.\n\n    assert.equal(result.allChecksPassed, true, JSON.stringify(result));\n\n\n###SOAP messages\n\nTo check a SOAP message make a call to messageCheckr as follows:\n\n    var result = messageCheckr({\n      type: 'soap',\n      actualMsg: actualMessage,\n      expectedMsg: expectedMessage\n    });\n\nIn the case of SOAP messages you don't need to specify the `expectedRootElement`, this is because it will automatically check the root element is `SOAP-ENV:Envelope`.\n\nWhen creating an `expectedMessage` for checking a SOAP message you need to specify the path using uppercase SOAP-ENV regardless of whether the actual message is using soap-env, soapenv or soap - all of these get converted to SOAP-ENV. When creating messageCheckr for a Java project I noticed when the app was deployed to Apache Tomcat the character case of SOAP-ENV was the opposite to what it was when deployed to IBM WebSphere. As the retrieval of a path is case sensitive there was a need to convert all references to SOAP-ENV to one character case.\n\nExample SOAP message\n\n    \u003csoap-env:Envelope xmlns:soap-env=\"http://schemas.xmlsoap.org/soap/envelope/\"\u003e\n      \u003csoap-env:Header/\u003e\n      \u003csoap-env:Body\u003e\n        \u003cm:elementOne\u003ehello\u003c/m:elementOne\u003e\n      \u003c/soap-env:Body\u003e\n    \u003c/soap-env:Envelope\u003e`\n\n\nLet's say we want to check the following for the above message:\n\n* \\\u003csoap-env:Envelope\\\u003e has the attribute `xmlns:soap-env` with the value `http://schemas.xmlsoap.org/soap/envelope/`\n* \\\u003cm:elementOne\\\u003e has the value `hello`\n\nCreate the expected message as follows:\n\n    var expectedMessage = [\n        {path: 'SOAP-ENV:Envelope', attribute: 'xmlns:SOAP-ENV', equals: 'http://schemas.xmlsoap.org/soap/envelope/'},\n        {path: 'SOAP-ENV:Envelope.SOAP-ENV:Body.elementOne', equals: 'hello'}\n    ];\n\nThen make a call to messageCheckr. Notice in the case of specifying the path for elementOne we have excluded the 'm' namespace, messageCheckr removes all non-SOAP namespaces. The decision for this again was related to differences I noticed when testing messageCheckr on different environments.\n\n###Position delimited messages\n\nTo check these \u003csarcasm\u003elovely\u003c/sarcasm\u003e position delimited messages you need to make a call to messageCheckr with type set to 'position':\n\n    var result = messageCheckr({\n      type: 'position',\n      actualMsg: actualMessage,\n      expectedMsg: expectedMessage\n    });\n\nExample position delimited message\n\n    start of messageNext part of message123456.10End of message\n\nLet's say we want to check the following for the above message:\n\n* Between position 0 and 15 the value is 'start of message'\n* Between position 16 and 35 the value contains 'part'\n* Between position 36 and 44 the value is 123456.10\n* Between position 36 and 44 the value is a number with 2 decimal places\n* Between position 45 and 58 the value matches the regex / of /\n\n`expectedMessage` is defined as follows:\n\n    var expectedMessage = [\n        {begin: 0,  end: 15, equals: 'start of message'},\n        {begin: 16, end: 35, contains: 'part'},\n        {begin: 36, end: 44, equals: 123456.10},\n        {begin: 36, end: 44, equals: '{number(2)}'},\n        {begin: 45, end: 58, equals: / of /}\n    ];\n\nexpectedMessage types for SOAP and JMS\n--------------------------------------\n\nThe following is a list of all possible types that you can use to construct an `expectedMessage`\n\n### Element by name\n- **{path: 'path.to.element', OPTIONS}**\n\nwhere **OPTIONS** can be one of the following:\n\n    - equals: operator - see section Operators\n    - equals: /regex containing utc-timezone or local-timezone/, dateFormat: 'see section Date Format'\n    - contains: 'string' or integer\n    - attribute: 'attribute name', equals: operator - see section Operators\n    - attribute: 'attribute name', equals: /regex containing utc-timezone or local-timezone/, dateFormat: 'see section Date Format'\n    - attribute: 'attribute name', contains: 'string' or integer\n    - pathShouldNotExist: true\n\n### Element by position\n- **{parentPath: 'path to parent of child element', element: 'name of element', elementPosition: integer \u003e 0, OPTIONS}**\n\nwhere **OPTIONS** can be one of the following:\n\n    - equals: operator - see section Operators\n    - equals: /regex containing utc-timezone or local-timezone/, dateFormat: 'see section Date Format'\n    - contains: 'string' or integer\n    - attribute: 'attribute name', equals: operator - see section Operators\n    - attribute: 'attribute name', equals: /regex containing utc-timezone or local-timezone/, dateFormat: 'see section Date Format'\n    - attribute: 'attribute name', contains: 'string' or integer\n    - pathShouldNotExist: true\n\n### Repeating groups of elements (where position is known)\n- **{repeatingGroup: {path: 'path to element containing repeating group', repeater: 'repeating group name', number: integer - occurrence}, path: 'element name', OPTIONS}**\n\nwhere **OPTIONS** can be one of the following:\n\n    - equals: operator - see section Operators\n    - equals: /regex containing utc-timezone or local-timezone/, dateFormat: 'see section Date Format'\n    - contains: 'string' or integer\n    - attribute: 'attribute name', equals: operator - see section Operators\n    - attribute: 'attribute name', equals: /regex containing utc-timezone or local-timezone/, dateFormat: 'see section Date Format'\n    - attribute: 'attribute name', contains: 'string' or integer\n    - pathShouldNotExist: true\n\n### Repeating groups of elements (where position cannot be guaranteed)\n\n- **{repeatingGroupHasElements: {\n            path: 'SOAP-ENV:ENVELOPE.SOAP-ENV:Body.thingContainingRepeatingGroups',\n            repeater: 'RepeatingGroup',\n            \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;elements: [\n                \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;{ path: 'fieldOneOfRepeatingGroup', OPTIONS },\n                \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;{ path: 'fieldTwoOfRepeatingGroup', OPTIONS }\n                \u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;]\n                \u0026nbsp;\u0026nbsp;}\n                }**\n\nwhere **OPTIONS** can be one of the following:\n\n    - equals: operator - see section Operators\n    - equals: /regex containing utc-timezone or local-timezone/, dateFormat: 'see section Date Format'\n    - contains: 'string' or integer\n    - attribute: 'attribute name', equals: operator - see section Operators\n    - attribute: 'attribute name', equals: /regex containing utc-timezone or local-timezone/, dateFormat: 'see section Date Format'\n    - attribute: 'attribute name', contains: 'string' or integer\n\n\nSee the [wiki](https://github.com/mrbenhowl/messageCheckr/wiki/expectedMessage-types-for-SOAP-and-JMS-in-detail) for a detailed example of each of the above expectedMessage types.\n\nOperators\n---------\n\nThe following is a list of operators (i.e. assertions) which can be applied to a value retrieved from the path specified.\n\n- **'string'**\n- **integer**\n- **'{integer}'**\n- **'{number(d)}' where d is an integer to indicate the number of expected decimal places**\n- **'{alpha}'**\n- **'{uuid}'**\n- **'{alphanumeric}'**\n- **'{length(\u003cd)}' where d is an integer**\n- **'{length(\u003ed)}' where d is an integer**\n- **'{length(d)}' where d is an integer**\n- **/regex/**\n- **/regex containing utc-timezone or local-timezone/**\n- **'{store(nameOfStore)}' and '{matches(nameOfStore)}'**\n\n### 'string'\n\nExpect 'string' value to be present. Works with `contains` and `equals`.\n\nExample:\n\n    equals: 'check this string equals the value at the path specified'\n    contains 'a string'\n\n### integer\n\nExpected the integer value to be present. Works with `contains` and `equals`.\n\nExample:\n\n    equals: 22\n    contains: 2\n\n### '{integer}'\n\nExpect the value to be an integer. Use with `equals`.\n\nExample:\n\n    equals: '{integer}'\n\n### '{number(d)}' where d is an integer to indicate the number of expected decimal places\n\nExpect the value to be number with d decimal places. Use with `equals`\n\nExample:\n\n    equals: '{number(2)}'\n\n### '{alpha}'\n\nExpect the value to be an alpha character or a sequence of alpha characters (A-Z a-z). Use with `equals`.\n\nExample:\n\n    equals: '{alpha}'\n    // e.g. 'a' or 'hello' would pass the assertion\n\n### '{uuid}'\n\nExpect the value to be an universally unique identifier (uuid). Use with `equals`.\n\nExample:\n\n    equals: '{uuid}'\n\n### '{alphanumeric}'\n\nExpect the value to be alphanumeric (A-Z a-z 0-9). Use with `equals`.\n\nExample:\n\n    equals: '{alphanumeric}'\n    // e.g. 'h3llo' would pass the assertion\n\n### '{length(\u003cd)}' where d is an integer\n\nExpect the value to have a length less than d. Use with `equals`.\n\nExample:\n\n    equals: '{length(\u003c6)}'\n    // e.g. 'hello' would pass the assertion\n\n### '{length(\u003ed)}' where d is an integer\n\nExpect the value to have a length greater than d. Use with `equals`.\n\nExample:\n\n    equals: '{length(\u003e5)}'\n    // e.g. 'hello' would pass the assertion\n\n### '{length(d)}' where d is an integer\n\nExpect the value to have a length equal to d. Use with `equals`.\n\nExample:\n\n    equals: '{length(5)}'\n    // e.g. 'hello' would pass the assertion\n\n\n### /regex/\n\nExpect the value to match the regex pattern. Use with `equals`.\n\nExample:\n\n    equals: /^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\\.[0-9]{3}\\+[0-9]{2}:[0-9]{2}/\n    // e.g. '2015-11-01T08:12:15.425+11:00' would pass the assertion\n\n**Remember to escape any special characters as this is just a JavaScript regex literal**\n\n### /regex containing utc-timezone or local-timezone/\n\nExpect the value to the match regex pattern after utc-timezone or local-timezone references have been replaced with the current date (assuming `dateFormat` has been included)\n\nExample:\n\n    equals: /local-timezoneT\\d\\d:\\d\\d:\\d\\d\\.\\d\\d\\d\\+\\d\\d:\\d\\d/, dateFormat: 'YYYY-MM-DD'\n    // YYYY-MM-DDT18:39:00.896+11:00 would pass the assertion if YYYY-MM-DD is the current local date\n\n**Remember to escape any special characters as this is just a JavaScript regex literal**\n\n### '{store(nameOfStore)}' and '{matches(nameOfStore)}'\n\nUse {store(nameOfStore)} to store the value specified by a path. Then use {matches(nameOfStore)} to check a different path value matches the value stored earlier. Use with `equals`.\n\n    \u003c?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?\u003e\n    \u003ctestRootElement xmlns=\"http://www.testing.com/integration/event\"\u003e\n       \u003celementOne\u003ehello\u003c/elementOne\u003e\n       \u003celementTwo\u003ehello\u003c/elementTwo\u003e\n    \u003c/testRootElement\u003e\n\n    var expectedMessage = [\n        {path: 'testRootElement.elementOne', equals: '{store(whatever)}'}\n        {path: 'testRootElement.elementTwo', equals: '{matches(whatever)}'}\n    ];\n\n    // in the example above we are asserting the value of \u003celementTwo\u003e matches the value of \u003celementOne\u003e\n\n\nDate Format (dateFormat)\n------------------------\n\nWhere a regex literal is used for `equals` and the attribute `dateFormat` is included then any reference to `local-timezone` or `utc-timezone` within the regex is replaced with the current local/utc date in the format specified in `dateFormat`. In the code Moment.js is used to format the current date as per the `dateFormat`. Refer to the following table for valid tokens:\n\n| Day of Month  | Examples                               |\n|---------------|----------------------------------------|\n| D             | 1 2 ... 30 31                          |\n| DD\t        | 01 02 ... 30 31                        |\n| Do\t        | 1st 2nd ... 30th 31st                  |\n\n| Month  | Examples                                            |\n|--------|-----------------------------------------------------|\n| M      | 1 2 ... 11 12                                       |\n| MM     | 01 to 12                                            |\n| Mo     | 1st 2nd ... 11th 12th, e.g January is the 1st month |\n| MMM\t | Jan Feb ... Nov Dec                                 |\n| MMMM\t | January February ... November December              |\n\n| Year  | Examples |\n|-------|----------|\n| YY    | 15       |\n| YYYY\t| 2016     |\n\n\nFor Contributors\n----------------\n\nTo run tests, node v4.0.0 or higher is required. I would recommend installing node version manager (nvm) if you haven't done so yet.\n\nClone the github repository:\n\n    git clone https://github.com/mrbenhowl/messageCheckr\n    cd messageCheckr\n    nvm use (optional - use if you use node version manager)\n    npm install\n\nTo run tests:\n\n    npm test\n\nTo run tests and see coverage:\n\n    npm run coverage\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrbenhowl%2Fmessagecheckr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrbenhowl%2Fmessagecheckr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrbenhowl%2Fmessagecheckr/lists"}