{"id":23413633,"url":"https://github.com/rmdm/power-assert-match","last_synced_at":"2025-04-09T05:15:35.705Z","repository":{"id":57329074,"uuid":"88775130","full_name":"rmdm/power-assert-match","owner":"rmdm","description":"power + assert-match \u003e:3","archived":false,"fork":false,"pushed_at":"2019-05-05T14:02:05.000Z","size":12,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-01T21:01:25.640Z","etag":null,"topics":["assert","assert-match","match","matchers","power-assert"],"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/rmdm.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":"2017-04-19T18:01:53.000Z","updated_at":"2017-05-05T01:16:46.000Z","dependencies_parsed_at":"2022-09-01T11:41:22.894Z","dependency_job_id":null,"html_url":"https://github.com/rmdm/power-assert-match","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmdm%2Fpower-assert-match","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmdm%2Fpower-assert-match/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmdm%2Fpower-assert-match/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmdm%2Fpower-assert-match/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rmdm","download_url":"https://codeload.github.com/rmdm/power-assert-match/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247980844,"owners_count":21027809,"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":["assert","assert-match","match","matchers","power-assert"],"created_at":"2024-12-22T19:53:53.436Z","updated_at":"2025-04-09T05:15:35.680Z","avatar_url":"https://github.com/rmdm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/rmdm/power-assert-match.svg?branch=master)](https://travis-ci.org/rmdm/power-assert-match)\n\npower-assert-match\n==================\n\n[assert-match](https://github.com/rmdm/assert-match) empowered.\n\nShort example\n=============\n\n```javascript\nimport assert from 'power-assert-match'\nconst { arrayOf, type } = assert.matchers\n\nconst nums = [ 1, 2, 'x' ]\nconst expectedType = 'number'\n\nassert.deepEqual({ nums: nums }, { nums: arrayOf(type(expectedType)) })\n\n//      AssertionError:   # test/power-assert-match.spec.js:30\n//\n//  assert.deepEqual({ nums: nums }, { nums: arrayOf(type(expectedType)) })\n//                   |       |       |       |       |    |\n//                   |       |       |       |       |    \"number\"\n//                   |       |       |       |       TypeMatcher{expected:\"number\"}\n//                   |       |       |       ArrayOfMatcher{expected:#TypeMatcher#}\n//                   |       |       Object{nums:#ArrayOfMatcher#}\n//                   |       [1,2,\"x\"]\n//                   Object{nums:#Array#}\n//\n//      + expected - actual\n//\n//       {\n//         \"nums\": [\n//           1\n//           2\n//      -    \"x\"\n//      +    {\n//      +      \"[typeof]\": \"number\"\n//      +    }\n//         ]\n//       }\n```\n\nInstallation\n============\n\n```sh\n    npm install power-assert-match\n```\n\nUsage\n=====\n\nUsage of `power-assert-match` is quite similar to that of\n[`power-assert`](https://github.com/power-assert-js/power-assert):\n\n1. require `power-assert-match`\n```javascript\nconst assert = require('power-assert-match')\n```\n2. use it\n``` javascript\nconst { loose } = assert.matchers\n\nconst actual = { a: 1, b: 2 }\nconst expected = { a: 10 }\n\nassert.deepEqual(actual, loose(expected))\n```\n3. to get descriptive messages like one in the example above you need to\ntransform your code using one of `power-assert` [instrumentors](https://github.com/power-assert-js/power-assert#be-sure-to-transform-test-code):\n\n - [espower-loader](https://github.com/power-assert-js/espower-loader) (with [intelli-espower-loader](https://github.com/power-assert-js/intelli-espower-loader))\n - [babel-preset-power-assert](https://github.com/power-assert-js/babel-preset-power-assert)\n - [babel-plugin-espower](https://github.com/power-assert-js/babel-plugin-espower)\n - [espowerify](https://github.com/power-assert-js/espowerify)\n - [webpack-espower-loader](https://github.com/power-assert-js/webpack-espower-loader).\n - [espower-cli](https://github.com/power-assert-js/espower-cli)\n - [grunt-espower](https://github.com/power-assert-js/grunt-espower)\n - [gulp-espower](https://github.com/power-assert-js/gulp-espower)\n - [karma-espower-preprocessor](https://github.com/power-assert-js/karma-espower-preprocessor)\n - [espower-coffee](https://github.com/power-assert-js/espower-coffee)\n - [espower-typescript](https://github.com/power-assert-js/espower-typescript)\n - [espower-traceur](https://github.com/power-assert-js/espower-traceur)\n\n**Note**, that unlike for `power-assert`, where `require('assert')` calls are\nsubstituted by the instrumentors with `require('power-assert')`, to use\n`power-assert-match` you need to require it directly.\n\nAfter applying transform you get the following output:\n\n```javascript\nassert.deepEqual(actual, loose(expected))\n                 |       |     |\n                 |       |     Object{a:10}\n                 |       LooseMatcher{expected:#Object#}\n                 Object{a:1,b:2}\n```\n\n\nMore output examples\n====================\n\n```javascript\nassert.deepEqual(val, not(val))\n                 |    |   |\n                 |    |   5\n                 5    NotMatcher{expected:5}\n\n\nassert.deepEqual(number, regex(numRegex))\n                 |       |     |\n                 |       |     /^\\d+$/\n                 \"555f\"  RegexMatcher{expected:/^\\d+$/}\n\n\nassert.deepEqual({ val: a }, { val: every([gt(b), lt(c)]) })\n                 |      |    |      |     ||  |   |  |\n                 |      |    |      |     ||  |   |  10\n                 |      |    |      |     ||  5   LtMatcher{expected:10}\n                 |      |    |      |     |GtMatcher{expected:5}\n                 |      |    |      |     [#GtMatcher#,#LtMatcher#]\n                 |      |    |      EveryMatcher{expected:#Array#}\n                 |      15   Object{val:#EveryMatcher#}\n                 Object{val:15}\n\n\nassert.deepEqual(actual, loose(expected))\n                 |       |     |\n                 |       |     Object{b:5}\n                 |       LooseMatcher{expected:#Object#}\n                 Object{a:1,b:2,c:3}\n\n\nassert.deepEqual(array, contains(val))\n                 |      |        |\n                 |      |        5\n                 |      ContainsMatcher{expected:5}\n                 [1,2,3]\n\n\nassert.deepEqual(obj, primitive(prim))\n                 |    |         |\n                 |    |         \"[object Arguments]\"\n                 |    PrimitiveMatcher{expected:\"[object Arguments]\"}\n                 Object{}\n\n\nassert.deepEqual(actual, expected)\n                 |       |\n                 |       Object{a:1,b:3,c:5}\n                 Object{a:1,b:2,c:3}\n```\n\nRelated projects\n================\n\n- [assert-match](https://github.com/rmdm/assert-match)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmdm%2Fpower-assert-match","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frmdm%2Fpower-assert-match","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmdm%2Fpower-assert-match/lists"}