{"id":13454878,"url":"https://github.com/power-assert-js/power-assert","last_synced_at":"2026-04-04T12:57:51.958Z","repository":{"id":10175249,"uuid":"12260386","full_name":"power-assert-js/power-assert","owner":"power-assert-js","description":"Power Assert in JavaScript. Provides descriptive assertion messages through standard assert interface. No API is the best API.","archived":false,"fork":false,"pushed_at":"2023-01-07T03:57:23.000Z","size":3179,"stargazers_count":2806,"open_issues_count":43,"forks_count":68,"subscribers_count":41,"default_branch":"master","last_synced_at":"2025-04-27T04:02:49.338Z","etag":null,"topics":["assert","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/power-assert-js.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-21T03:35:26.000Z","updated_at":"2025-04-16T02:09:47.000Z","dependencies_parsed_at":"2023-01-13T15:47:00.517Z","dependency_job_id":null,"html_url":"https://github.com/power-assert-js/power-assert","commit_stats":null,"previous_names":[],"tags_count":40,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/power-assert-js%2Fpower-assert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/power-assert-js%2Fpower-assert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/power-assert-js%2Fpower-assert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/power-assert-js%2Fpower-assert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/power-assert-js","download_url":"https://codeload.github.com/power-assert-js/power-assert/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252389403,"owners_count":21740128,"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","power-assert"],"created_at":"2024-07-31T08:00:58.859Z","updated_at":"2025-12-17T00:23:20.247Z","avatar_url":"https://github.com/power-assert-js.png","language":"JavaScript","readme":"[![power-assert][power-assert-banner]][power-assert-url]\n\nPower Assert in JavaScript. Provides descriptive assertion messages through standard [assert](https://nodejs.org/api/assert.html) interface. No API is the best API.\n\n[![Build Status][travis-image]][travis-url]\n[![NPM package][npm-image]][npm-url]\n[![Bower package][bower-image]][bower-url]\n[![License][license-image]][license-url]\n\n\nDESCRIPTION\n---------------------------------------\n\nWhat is `power-assert`?\n\n * is an implementation of \"Power Assert\" concept in JavaScript.\n * provides descriptive assertion messages through standard [assert](https://nodejs.org/api/assert.html) interface.\n * __No API is the best API__. With power-assert, __you don't need to learn many assertion library APIs__ (in most cases, all you need to remember is just an `assert(any_expression)` function)\n * __Stop memorizing tons of assertion APIs. Just create expressions that return a truthy value or not__ and power-assert will show it to you right on the screen as part of your failure message without you having to type in a message at all.\n * the core value of power-assert is absolute simplicity and stability. Especially, power-assert sticks to the simplest form of testing, `assert(any_expression)`.\n * see slides: [\"power-assert, mechanism and philosophy\"](https://www.slideshare.net/t_wada/power-assert-nodefest-2014) -- talk at NodeFest 2014.\n * __[NEW] Now you don't need `require('power-assert')` any more. Keep using `require('assert')`, and power-assert enhances them transparently.__ See slides: [From Library to Tool - power-assert as a General Purpose Assertion Enhancement Tool](https://speakerdeck.com/twada/from-library-to-tool-power-assert-as-a-general-purpose-assertion-enhancement-tool)\n * to gain power-assert output, __you need to transform your test code__ to produce power-assert output.\n * `power-assert - power = assert`. Without code transpilation, power-assert works just as normal `assert` does.\n * fully compatible with [assert](https://nodejs.org/api/assert.html). So you can stop using power-assert and back to assert easily.\n * has [online demo site](https://azu.github.io/power-assert-demo/).\n * works both on server side and browser side.\n * available via [npm](https://www.npmjs.com/package/power-assert) and [bower](https://bower.io/search/?q=power-assert). \n * supports sourcemaps so you can debug as usual.\n * provides [babel plugin](https://github.com/power-assert-js/babel-plugin-espower) and [babel preset](https://github.com/power-assert-js/babel-preset-power-assert).\n * provides [browserify transform](https://github.com/power-assert-js/espowerify).\n * provides [webpack loader](https://github.com/power-assert-js/webpack-espower-loader).\n * provides [grunt task](https://github.com/power-assert-js/grunt-espower) and [gulp plugin](https://github.com/power-assert-js/gulp-espower).\n * provides [command](https://github.com/power-assert-js/espower-cli).\n * provides [custom module loader](https://github.com/power-assert-js/espower-loader) and its [convenient config module](https://github.com/power-assert-js/intelli-espower-loader).\n * provides [Karma Adapter](https://github.com/power-assert-js/karma-power-assert) and [Karma Preprocessor](https://github.com/power-assert-js/karma-espower-preprocessor).\n * supports ES6+ through [babel plugin](https://github.com/power-assert-js/babel-plugin-espower).\n * supports [CoffeeScript](https://github.com/power-assert-js/espower-coffee).\n * supports [TypeScript](https://github.com/power-assert-js/espower-typescript).\n * has [TypeScript type definition](https://www.npmjs.com/package/@types/power-assert)\n * has code migration tool that transforms existing code from [chai](https://github.com/twada/chai-to-assert), [should.js](https://github.com/node-modules/should2assert) and [expect.js](https://github.com/twada/expect-js-to-assert) to assert.\n * [AVA](https://github.com/avajs/ava), the futuristic test runner, now [comes with power-assert builtin](https://github.com/avajs/ava#enhanced-assertion-messages)\n * has [Lab transformer](https://github.com/feugy/lab-espower-transformer) to enable power-assert on [Lab](https://github.com/hapijs/lab)\n * has [module loader](https://github.com/tracecomms/espower-ts-node) to get [ts-node](https://github.com/TypeStrong/ts-node) working together with power-assert\n * [Wallaby.js](https://wallabyjs.com/) supports power-assert via [Babel compiler/preprocessor](https://github.com/wallabyjs/public/issues/754#issuecomment-241624868)\n * pull-requests, issue reports and patches are always welcomed.\n\n\n`power-assert` provides descriptive assertion messages for your tests, like this.\n\n      1) Array #indexOf() should return index when the value is present:\n         AssertionError: # path/to/test/mocha_node.js:10\n    \n      assert(ary.indexOf(zero) === two)\n             |   |       |     |   |\n             |   |       |     |   2\n             |   -1      0     false\n             [1,2,3]\n    \n      [number] two\n      =\u003e 2\n      [number] ary.indexOf(zero)\n      =\u003e -1\n\n\nAPI\n---------------------------------------\n\npower-assert enhances these assert functions by [espower](https://github.com/power-assert-js/espower). Produces descriptive message when assertion is failed.\n\n* [`assert(value, [message])`](https://nodejs.org/api/assert.html#assert_assert_value_message)\n* [`assert.ok(value, [message])`](https://nodejs.org/api/assert.html#assert_assert_ok_value_message)\n* [`assert.equal(actual, expected, [message])`](https://nodejs.org/api/assert.html#assert_assert_equal_actual_expected_message)\n* [`assert.notEqual(actual, expected, [message])`](https://nodejs.org/api/assert.html#assert_assert_notequal_actual_expected_message)\n* [`assert.strictEqual(actual, expected, [message])`](https://nodejs.org/api/assert.html#assert_assert_strictequal_actual_expected_message)\n* [`assert.notStrictEqual(actual, expected, [message])`](https://nodejs.org/api/assert.html#assert_assert_notstrictequal_actual_expected_message)\n* [`assert.deepEqual(actual, expected, [message])`](https://nodejs.org/api/assert.html#assert_assert_deepequal_actual_expected_message)\n* [`assert.notDeepEqual(actual, expected, [message])`](https://nodejs.org/api/assert.html#assert_assert_notdeepequal_actual_expected_message)\n* [`assert.deepStrictEqual(actual, expected, [message])`](https://nodejs.org/api/assert.html#assert_assert_deepstrictequal_actual_expected_message)\n* [`assert.notDeepStrictEqual(actual, expected, [message])`](https://nodejs.org/api/assert.html#assert_assert_notdeepstrictequal_actual_expected_message)\n\npower-assert is fully compatible with [assert](https://nodejs.org/api/assert.html). So functions below are also available though they are not enhanced (does not produce descriptive message).\n\n* [`assert.fail(actual, expected, message, operator)`](https://nodejs.org/api/assert.html#assert_assert_fail_actual_expected_message_operator_stackstartfunction)\n* [`assert.throws(block, [error], [message])`](https://nodejs.org/api/assert.html#assert_assert_throws_block_error_message)\n* [`assert.doesNotThrow(block, [message])`](https://nodejs.org/api/assert.html#assert_assert_doesnotthrow_block_error_message)\n* [`assert.ifError(value)`](https://nodejs.org/api/assert.html#assert_assert_iferror_value)\n\nSince version 1.5.0, power-assert supports [\"strict mode\"](https://nodejs.org/api/assert.html#assert_strict_mode) as well.\n\npower-assert provides an [API for customization](https://github.com/power-assert-js/power-assert#customization-api).\n\n* `assert.customize(options)`\n\n\n### No API is the best API\n\nThough power-assert is fully compatible with standard [assert](https://nodejs.org/api/assert.html) interface, all you need to remember is just an `assert(any_expression)` function in most cases.\n\nThe core value of power-assert is absolute simplicity and stability. Especially, power-assert sticks to the simplest form of testing, `assert(any_expression)`.\n\n\n        assert(types[index].name === bob.name)\n               |    ||      |    |   |   |\n               |    ||      |    |   |   \"bob\"\n               |    ||      |    |   Person{name:\"bob\",age:5}\n               |    ||      |    false\n               |    |11     \"alice\"\n               |    Person{name:\"alice\",age:3}\n               [\"string\",98.6,true,false,null,undefined,#Array#,#Object#,NaN,Infinity,/^not/,#Person#]\n      \n        --- [string] bob.name\n        +++ [string] types[index].name\n        @@ -1,3 +1,5 @@\n        -bob\n        +alice\n\n\nFAQ\n---------------------------------------\n\n- [Support other assertion styles?](https://github.com/power-assert-js/power-assert/issues/22)\n- [Does this work with substack/tape?](https://github.com/power-assert-js/power-assert/issues/30)\n- [Are all dependencies required at runtime?](https://github.com/power-assert-js/power-assert/issues/24)\n- [Descriptive assertion message does not appear when writing tests in ES6 with Babel](https://github.com/power-assert-js/webpack-espower-loader/issues/4#issuecomment-139605343)\n- [Incomplete increment/decrement assertion messages?](https://github.com/power-assert-js/power-assert/issues/32)\n- [Cannot capture not invokable method error](https://github.com/power-assert-js/power-assert/issues/36)\n- What is the ['Critical dependencies' warning shown by webpack](https://github.com/power-assert-js/babel-plugin-espower/issues/14#issuecomment-197272436) and how to [suppress warnings](https://github.com/power-assert-js/babel-plugin-espower/issues/14#issuecomment-197909419)?\n- [Causes `TypeError: assert._capt is not a function`](https://github.com/power-assert-js/power-assert/issues/42)\n- [How to deal with `assert` calls in production](https://github.com/power-assert-js/power-assert/issues/43#issuecomment-208851919)\n- [Support JSX tags?](https://github.com/power-assert-js/power-assert/issues/34#issuecomment-269848058)\n- [Any tool to migrate `should/expect` code to `power-assert`?](https://github.com/power-assert-js/power-assert/issues/74)\n- [Conflicts with babel-plugin-istanbul?](https://github.com/power-assert-js/babel-preset-power-assert/issues/4)\n- [power-assert message does not appear in Node8](https://github.com/power-assert-js/power-assert/issues/85)\n\n\nINSTALL\n---------------------------------------\n\n`npm install --save-dev power-assert \u003cone of instrumentors\u003e`\n\nor\n\n```\nbower install --save-dev power-assert\nnpm install --save-dev \u003cone of instrumentors\u003e\n```\n\nsee [list of instrumentors](https://github.com/power-assert-js/power-assert#be-sure-to-transform-test-code)\n\n\nCHANGELOG\n---------------------------------------\nSee [CHANGELOG](https://github.com/power-assert-js/power-assert/blob/master/CHANGELOG.md)\n\n\nEXAMPLE\n---------------------------------------\n\nSee [HOW TO USE](https://github.com/power-assert-js/power-assert#how-to-use) section for more details.\n\n__Note:__ There is an [online demo site](https://azu.github.io/power-assert-demo/) available.\n\n\n### Target test code (using Mocha in this example)\n\n```javascript\n'use strict';\n\nconst assert = require('assert');\n\ndescribe('Array', function(){\n    let ary;\n    beforeEach(() =\u003e {\n        ary = [1,2,3];\n    });\n    describe('#indexOf()', () =\u003e {\n        it('should return index when the value is present', () =\u003e {\n            const zero = 0, two = 2;\n            assert(ary.indexOf(zero) === two);\n        });\n        it('should return -1 when the value is not present', () =\u003e {\n            const minusOne = -1, two = 2;\n            assert.ok(ary.indexOf(two) === minusOne, 'THIS IS AN ASSERTION MESSAGE');\n        });\n    });\n});\n\ndescribe('various types', () =\u003e {\n    let types;\n    class Person {\n        constructor(name, age) {\n            this.name = name;\n            this.age = age;\n        }\n    }\n    beforeEach(() =\u003e {\n        types = [\n            'string', 98.6, true, false, null, undefined,\n            ['nested', 'array'],\n            {object: true},\n            NaN, Infinity,\n            /^not/,\n            new Person('alice', 3)\n        ];\n    });\n    it('demo', () =\u003e {\n        const index = types.length -1,\n            bob = new Person('bob', 5);\n        assert(types[index].name === bob.name);\n    });\n});\n```\n\n### Be sure to transform test code\n\nTo use power-assert, you need to transform your test code for power-assert output.\n\nCode transform is done by instrumentors below:\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\nIf you are using Node.js only, the easiest way is to use [intelli-espower-loader](https://github.com/power-assert-js/intelli-espower-loader). Steps are as follows.\n\n\n### Setup\n\n`npm install --save-dev mocha power-assert intelli-espower-loader`\n\n\n### Run\n\nPut tests into `test` directory then run. You will see the power-assert output appears.\n\n      $ $(npm bin)/mocha --require intelli-espower-loader path/to/test/mocha_node.js\n    \n    \n      Array\n        #indexOf()\n          1) should return index when the value is present\n          2) should return -1 when the value is not present\n    \n      various types\n        3) demo\n    \n    \n      0 passing (43ms)\n      3 failing\n    \n      1) Array #indexOf() should return index when the value is present:\n    \n          AssertionError:   # test/example2.js:13\n    \n      assert(ary.indexOf(zero) === two)\n             |   |       |     |   |\n             |   |       |     |   2\n             |   -1      0     false\n             [1,2,3]\n    \n      [number] two\n      =\u003e 2\n      [number] ary.indexOf(zero)\n      =\u003e -1\n    \n          + expected - actual\n    \n          -false\n          +true\n    \n          at Context.it (test/example2.js:13:13)\n    \n      2) Array #indexOf() should return -1 when the value is not present:\n    \n          AssertionError: THIS IS AN ASSERTION MESSAGE   # test/example2.js:17\n    \n      assert.ok(ary.indexOf(two) === minusOne, 'THIS IS AN ASSERTION MESSAGE')\n                |   |       |    |   |\n                |   |       |    |   -1\n                |   1       2    false\n                [1,2,3]\n    \n      [number] minusOne\n      =\u003e -1\n      [number] ary.indexOf(two)\n      =\u003e 1\n    \n          + expected - actual\n    \n          -false\n          +true\n    \n          at Context.it (test/example2.js:17:20)\n    \n      3) various types demo:\n    \n          AssertionError:   # test/example2.js:43\n    \n      assert(types[index].name === bob.name)\n             |    ||      |    |   |   |\n             |    ||      |    |   |   \"bob\"\n             |    ||      |    |   Person{name:\"bob\",age:5}\n             |    ||      |    false\n             |    |11     \"alice\"\n             |    Person{name:\"alice\",age:3}\n             [\"string\",98.6,true,false,null,undefined,#Array#,#Object#,NaN,Infinity,/^not/,#Person#]\n    \n      --- [string] bob.name\n      +++ [string] types[index].name\n      @@ -1,3 +1,5 @@\n      -bob\n      +alice\n    \n    \n          + expected - actual\n    \n          -false\n          +true\n    \n          at Context.it (test/example2.js:43:9)\n\n\n\nSEED PROJECTS\n---------------------------------------\n\nSome seed projects are available to help you start with power-assert.\n\n| module | env | tech stack |\n|:-------|:------------|:------------|\n| [power-assert-node-seed](https://github.com/azu/power-assert-node-seed) | Node.js | power-assert + [intelli-espower-loader](https://github.com/power-assert-js/intelli-espower-loader) |\n| [power-assert-testem-seed](https://github.com/azu/power-assert-testem-seed) | Browsers(by [testem](https://github.com/testem/testem)) | power-assert + [gulp-espower](https://github.com/power-assert-js/gulp-espower) + [testem](https://github.com/airportyh/testem). |\n| [power-assert-karma-seed](https://github.com/azu/power-assert-karma-seed) | Browsers(by [Karma](https://karma-runner.github.io/)) | power-assert + [espowerify](https://github.com/power-assert-js/espowerify) + [browserify](http://browserify.org/) + [Karma](https://karma-runner.github.io/). |\n\n\nHOW TO USE\n---------------------------------------\n\nThere are some ways to use power-assert. (If you want to see running examples, see [SEED PROJECTS](#seed-projects))\n\n1. `power-assert` + `Babel` + `babel-preset-power-assert`: The only way to enable power-assert if you are using [Babel6+](https://babeljs.io/).\n2. `power-assert` + `espower-loader` or `intelli-espower-loader` : Simple and recommended (but only works under Node).\n3. `power-assert` + `espower-coffee` or `espower-typescript`: Use power-assert with AltJS. Recommended but only works under Node.\n4. `power-assert` + `browserify` + `espowerify`: if you are using [browserify](http://browserify.org/) but not with Babel.\n5. `power-assert` + `webpack` + `webpack-espower-loader`: if you are using [webpack](https://webpack.github.io/) but not with Babel.\n6. `power-assert` + `espower-cli` or `grunt-espower` or `gulp-espower` : Generate instrumented code so works anywhere.\n\n\n### using `babel-preset-power-assert` or `babel-plugin-espower`\n\nIf you are writing your code with Babel, you can instrument Power Assert feature with Babel and babel-preset-power-assert (or babel-plugin-espower).\n\nsee [babel-plugin-espower README](https://github.com/power-assert-js/babel-plugin-espower) and [babel-preset-power-assert README](https://github.com/power-assert-js/babel-preset-power-assert)\n\n\n### using `espower-loader` or `intelli-espower-loader`\n\nIf you are writing Node.js app/module, you can instrument Power Assert feature without code generation by using `espower-loader`.\n\nsee [espower-loader README](https://github.com/power-assert-js/espower-loader).\n\nFYI: You may be interested in [intelli-espower-loader](https://github.com/power-assert-js/intelli-espower-loader) to go one step further. With [intelli-espower-loader](https://github.com/power-assert-js/intelli-espower-loader), you don't need to create loader file (like `enable-power-assert.js`). Just define test directory in `package.json` wow!\n\n\n### using `espower-typescript`\n\nIf you are writing Node.js app/module in TypeScript, you can instrument Power Assert feature without code generation by using `espower-typescript`.\n\nsee [espower-typescript README](https://github.com/power-assert-js/espower-typescript).\n\n\n### using `espower-coffee`\n\nIf you are writing Node.js app/module in CoffeeScript, you can instrument Power Assert feature without code generation by using `espower-coffee`.\n\nsee [espower-coffee README](https://github.com/power-assert-js/espower-coffee).\n\n\n### using `espowerify`\n\nIf you are using [browserify](http://browserify.org/) but not with Babel, you can instrument Power Assert feature via `espowerify`.\n\nsee [espowerify README](https://github.com/power-assert-js/espowerify).\n\n\n### using `webpack-espower-loader`\n\nIf you are using [webpack](https://webpack.github.io/) but not with Babel, you can instrument Power Assert feature via `webpack-espower-loader`.\n\nsee [webpack-espower-loader README](https://github.com/power-assert-js/webpack-espower-loader).\n\n\n### using `espower-cli`\n\nIf you don't want to use grunt, gulp, browserify, and so on, you can use `power-assert` via bower, with generated code by `espower-cli`\n\nsee [espower-cli README](https://github.com/power-assert-js/espower-cli).\n\n\n### using `gulp-espower`\n\nOn the browser side and you are not using [browserify](http://browserify.org/) but [bower](https://bower.io/) and [gulp](http://gulpjs.com/), you can use `power-assert` via bower, with generated code by `gulp-espower`\n\nsee [gulp-espower README](https://github.com/power-assert-js/gulp-espower).\n\n\n### using `grunt-espower`\n\nOn the browser side and you are not using [browserify](http://browserify.org/) but [bower](https://bower.io/) and [Grunt](http://gruntjs.com/), you can use `power-assert` via bower, with generated code by `grunt-espower`\n\nsee [grunt-espower README](https://github.com/power-assert-js/grunt-espower).\n\n\n\nCUSTOMIZATION API\n---------------------------------------\n\n`power-assert` provides an API for customization.\n\n### var assert = assert.customize(options)\n\nThrough this API, you can customize power-assert by changing some options.\n\n```javascript\nvar assert = require('power-assert').customize({\n    output: {\n        maxDepth: 2\n    }\n});\n```\n\n### options\n\n`options` has two top-level keys. `assertion` and `output`.\n\n#### options.assertion\n\ncustomization options for [empower](https://github.com/power-assert-js/empower) module. See [empower API documentation](https://github.com/power-assert-js/empower#api) for details. Note that some default values are different from `empower`'s (`modifyMessageOnRethrow: true` and `saveContextOnRethrow: true`).\n\n#### options.output\n\ncustomization options for [power-assert-formatter](https://github.com/power-assert-js/power-assert-formatter) module. See [power-assert-formatter API documentation](https://github.com/power-assert-js/power-assert-formatter#api) for details.\n\n#### default values\n\ncustomizable properties and their default values are as follows.\n\n```javascript\nvar assert = require('power-assert').customize({\n    assertion: {\n        destructive: false,\n        modifyMessageOnRethrow: true,\n        saveContextOnRethrow: true,\n        patterns: [\n            'assert(value, [message])',\n            'assert.ok(value, [message])',\n            'assert.equal(actual, expected, [message])',\n            'assert.notEqual(actual, expected, [message])',\n            'assert.strictEqual(actual, expected, [message])',\n            'assert.notStrictEqual(actual, expected, [message])',\n            'assert.deepEqual(actual, expected, [message])',\n            'assert.notDeepEqual(actual, expected, [message])',\n            'assert.deepStrictEqual(actual, expected, [message])',\n            'assert.notDeepStrictEqual(actual, expected, [message])'\n        ]\n    },\n    output: {\n        lineDiffThreshold: 5,\n        maxDepth: 1,\n        anonymous: 'Object',\n        circular: '#@Circular#',\n        lineSeparator: '\\n',\n        ambiguousEastAsianCharWidth: 2,\n        widthOf: (Function to calculate width of string. Please see power-assert-formatter's documentation)\n        stringify: (Function to stringify any target value. Please see power-assert-formatter's documentation)\n        diff: (Function to create diff string between two strings. Please see power-assert-formatter's documentation)\n        writerClass: (Constructor Function for output writer class. Please see power-assert-formatter's documentation)\n        renderers: [\n            './built-in/file',\n            './built-in/assertion',\n            './built-in/diagram',\n            './built-in/binary-expression'\n        ]\n    }\n});\n```\n\n\nINTERNAL DESIGN\n---------------------------------------\n\n`power-assert` family provides 1 main module, 4 core modules and many more instrumentors.\n\n\nMain (facade) module is,\n\n| module | description |\n|:-------|:------------|\n| [power-assert](https://github.com/power-assert-js/power-assert) | Standard `assert` function on top of `empower` and `power-assert-formatter` |\n\ncore modules are,\n\n| module | description |\n|:-------|:------------|\n| [empower](https://github.com/power-assert-js/empower) | Power Assert feature enhancer for assert function/object. |\n| [power-assert-formatter](https://github.com/power-assert-js/power-assert-formatter) | Power Assert output formatter. |\n| [espower](https://github.com/power-assert-js/espower) | Power Assert feature instrumentor core based on the ECMAScript AST defined in [The ESTree Spec](https://github.com/estree/estree) (formerly known as [Mozilla SpiderMonkey Parser API](https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Parser_API)). |\n| [espower-source](https://github.com/power-assert-js/espower-source) | Power Assert instrumentor from source to source, with source-map. (Thin wrapper of `espower`). |\n\nand instrumentors are,\n\n| module | description |\n|:-------|:------------|\n| [espower-loader](https://github.com/power-assert-js/espower-loader) | Node module loader to apply `espower` on the fly. |\n| [intelli-espower-loader](https://github.com/power-assert-js/intelli-espower-loader) | configure `espower-loader` with ease. |\n| [babel-preset-power-assert](https://github.com/power-assert-js/babel-preset-power-assert) | [Babel](https://babeljs.io/) preset to instrument power-assert feature into target files. |\n| [babel-plugin-espower](https://github.com/power-assert-js/babel-plugin-espower) | [Babel](https://babeljs.io/) plugin to instrument power-assert feature into target files. |\n| [espowerify](https://github.com/power-assert-js/espowerify) | [Browserify](http://browserify.org/) transform to apply `espower` to target files. |\n| [webpack-espower-loader](https://github.com/power-assert-js/webpack-espower-loader) | Power Assert instrumentor module for [webpack](https://webpack.github.io/). |\n| [espower-cli](https://github.com/power-assert-js/espower-cli) | Command line tool for power-assert. |\n| [grunt-espower](https://github.com/power-assert-js/grunt-espower) | Grunt task to apply `espower` to target files. |\n| [gulp-espower](https://github.com/power-assert-js/gulp-espower) | Gulp plugin to apply `espower` to target files. |\n| [karma-espower-preprocessor](https://github.com/power-assert-js/karma-espower-preprocessor) | karma-preprocessor for power-assert. |\n| [espower-coffee](https://github.com/power-assert-js/espower-coffee) | power-assert instrumentor for CoffeeScript. |\n| [espower-typescript](https://github.com/power-assert-js/espower-typescript) | power-assert instrumentor for TypeScript. |\n| [espower-traceur](https://github.com/power-assert-js/espower-traceur) | power-assert instrumentor for ES6 using [Traceur Compiler](https://github.com/google/traceur-compiler/). |\n| [espower-babel](https://github.com/power-assert-js/espower-babel) | [DEPRECATED] power-assert instrumentor for ES6 using [Babel](https://babeljs.io/). |\n\n\n`power-assert` provides standard [assert](https://nodejs.org/api/assert.html) compatible function with Power Assert feature.\n(Best fit with [Mocha](https://mochajs.org/). If you use assert-like objects provided by various testing frameworks such as [QUnit](https://qunitjs.com/) or [nodeunit](https://github.com/caolan/nodeunit). Please use [empower](https://github.com/power-assert-js/empower) and [power-assert-formatter](https://github.com/power-assert-js/power-assert-formatter) modules directly).\n\n\nInternally, `power-assert` uses [empower](https://github.com/power-assert-js/empower) module to enhance power assert feature into the standard [assert](https://nodejs.org/api/assert.html) module, to run with the power assert feature added code by [espower](https://github.com/power-assert-js/espower) module, and prettify output using [power-assert-formatter](https://github.com/power-assert-js/power-assert-formatter).\n\n\nSee [power-assert-demo](https://github.com/twada/power-assert-demo) project for power-assert Demo running with mocha.\n\n\nSUPPORTED FRAMEWORKS\n---------------------------------------\n\n* [Mocha](https://mochajs.org/)\n* [AVA](https://github.com/sindresorhus/ava)\n\n\n### FRAMEWORKS KNOWN TO WORK\n\n* [Jest](https://facebook.github.io/jest/) with Babel\n* [Karma](https://karma-runner.github.io/) with Mocha\n* [testem](https://github.com/testem/testem) with Mocha\n* [QUnit](https://qunitjs.com/)\n* [nodeunit](https://github.com/caolan/nodeunit)\n* [buster-assertions](https://docs.busterjs.org/en/latest/modules/buster-assertions/)\n* [Lab](https://github.com/hapijs/lab)\n* [Nightmare](http://www.nightmarejs.org/)\n* [Protractor](http://www.protractortest.org/)\n* [eater](https://github.com/yosuke-furukawa/eater)\n\n\nOUR SUPPORT POLICY\n---------------------------------------\n\nFor the Transpiler side, we support Node under maintenance. In other words, we stop supporting old Node version when [their maintenance ends](https://github.com/nodejs/LTS).\n\nFor the Runtime side, we support [Node under maintenance](https://github.com/nodejs/LTS) and \"modern enough\" browsers such as Chrome, Firefox, Safari, Edge etc.\n\nAny other environments are not supported officially (means that we do not test against them on CI service). power-assert is known to work with old browsers, and trying to keep them working though.\n\n\nAUTHOR\n---------------------------------------\n* [Takuto Wada](https://github.com/twada)\n\n\nCONTRIBUTORS\n---------------------------------------\n* [azu (azu)](https://github.com/azu)\n* [vvakame (Masahiro Wakame)](https://github.com/vvakame)\n* [yosuke-furukawa (Yosuke Furukawa)](https://github.com/yosuke-furukawa)\n* [teppeis (Teppei Sato)](https://github.com/teppeis)\n* [zoncoen (Kenta Mori)](https://github.com/zoncoen)\n* [falsandtru (falsandtru)](https://github.com/falsandtru)\n* [jamestalmage (James Talmage)](https://github.com/jamestalmage)\n* [LeshaKoss (Lesha Koss)](https://github.com/LeshaKoss)\n* [watilde (Daijirō Wachi)](https://github.com/watilde)\n\n\nLICENSE\n---------------------------------------\nLicensed under the [MIT](https://github.com/power-assert-js/power-assert/blob/master/MIT-LICENSE.txt) license.\n\n\n\nMORE OUTPUT EXAMPLES\n---------------------------------------\n\n### Target test code (using QUnit in this example)\n\n```javascript\nvar q = require('qunitjs');\n\n(function () {\n    var empower = require('empower'),\n        formatter = require('power-assert-formatter'),\n        qunitTap = require(\"qunit-tap\");\n    empower(q.assert, formatter(), {destructive: true});\n    qunitTap(q, require('util').puts, {showSourceOnFailure: false});\n    q.config.autorun = false;\n})();\n\nq.test('spike', function (assert) {\n    assert.ok(true);\n\n    var hoge = 'foo';\n    var fuga = 'bar';\n    assert.ok(hoge === fuga, 'comment');\n\n    var piyo = 3;\n    assert.ok(fuga === piyo);\n\n    var longString = 'very very loooooooooooooooooooooooooooooooooooooooooooooooooooong message';\n    var anotherLongString = 'yet another loooooooooooooooooooooooooooooooooooooooooooooooooooong message';\n    assert.ok(longString === anotherLongString);\n\n    assert.ok(4 === piyo);\n\n    assert.ok(4 !== 4);\n\n    var falsyStr = '';\n    assert.ok(falsyStr);\n\n    var falsyNum = 0;\n    assert.ok(falsyNum);\n\n    var ary1 = ['foo', 'bar'];\n    var ary2 = ['aaa', 'bbb', 'ccc'];\n    assert.ok(ary1.length === ary2.length);\n    assert.deepEqual(ary1, ary2);\n\n    var actual = 16;\n    assert.ok(5 \u003c actual \u0026\u0026 actual \u003c 13);\n\n    actual = 4;\n    assert.ok(5 \u003c actual \u0026\u0026 actual \u003c 13);\n\n    actual = 10;\n    assert.ok(actual \u003c 5 || 13 \u003c actual);\n\n\n    var propName = 'bar',\n        foo = {\n            bar: {\n                baz: false\n            }\n        };\n\n    assert.ok(foo.bar.baz);\n    assert.ok(foo['bar'].baz);\n    assert.ok(foo[propName]['baz']);\n\n\n    var truth = true;\n    assert.ok(!truth);\n\n\n    var func = function () { return false; };\n    assert.ok(func());\n\n\n    var obj = {\n        age: function () {\n            return 0;\n        }\n    };\n    assert.ok(obj.age());\n\n\n    var isFalsy = function (arg) {\n        return !(arg);\n    };\n    var positiveInt = 50;\n    assert.ok(isFalsy(positiveInt));\n\n\n    var sum = function () {\n        var result = 0;\n        for (var i = 0; i \u003c arguments.length; i += 1) {\n            result += arguments[i];\n        }\n        return result;\n    };\n    var one = 1, two = 2, three = 3, seven = 7, ten = 10;\n    assert.ok(sum(one, two, three) === seven);\n    assert.ok(sum(sum(one, two), three) === sum(sum(two, three), seven));\n    assert.ok((three * (seven * ten)) === three);\n\n\n    var math = {\n        calc: {\n            sum: function () {\n                var result = 0;\n                for (var i = 0; i \u003c arguments.length; i += 1) {\n                    result += arguments[i];\n                }\n                return result;\n            }\n        }\n    };\n    assert.ok(math.calc.sum(one, two, three) === seven);\n});\n\nq.load();\n```\n\n\n### `espower` code above then running under Node.js\n    \n```\n# module: undefined\n# test: spike\nok 1 - okay\nnot ok 2 - comment # path/to/examples/qunit_node.js:17\n#\n# assert.ok(hoge === fuga, 'comment')\n#           |    |   |\n#           |    |   \"bar\"\n#           |    false\n#           \"foo\"\n#\n# --- [string] fuga\n# +++ [string] hoge\n# @@ -1,3 +1,3 @@\n# -bar\n# +foo\n#\n# , test: spike\nnot ok 3 - # path/to/examples/qunit_node.js:20\n#\n# assert.ok(fuga === piyo)\n#           |    |   |\n#           |    |   3\n#           |    false\n#           \"bar\"\n#\n# [number] piyo\n# =\u003e 3\n# [string] fuga\n# =\u003e \"bar\"\n\n# , test: spike\nnot ok 4 - # path/to/examples/qunit_node.js:24\n#\n# assert.ok(longString === anotherLongString)\n#           |          |   |\n#           |          |   \"yet another loooooooooooooooooooooooooooooooooooooooooooooooooooong message\"\n#           |          false\n#           \"very very loooooooooooooooooooooooooooooooooooooooooooooooooooong message\"\n#\n# --- [string] anotherLongString\n# +++ [string] longString\n# @@ -1,15 +1,13 @@\n# -yet anoth\n# +very v\n#  er\n# +y\n#   loo\n#\n# , test: spike\nnot ok 5 - # path/to/examples/qunit_node.js:26\n#\n# assert.ok(4 === piyo)\n#             |   |\n#             |   3\n#             false\n#\n# [number] piyo\n# =\u003e 3\n# [number] 4\n# =\u003e 4\n# , test: spike\nnot ok 6 - # path/to/examples/qunit_node.js:28\n#\n# assert.ok(4 !== 4)\n#             |\n#             false\n# , test: spike\nnot ok 7 - # path/to/examples/qunit_node.js:31\n#\n# assert.ok(falsyStr)\n#           |\n#           \"\"\n# , test: spike\nnot ok 8 - # path/to/examples/qunit_node.js:34\n#\n# assert.ok(falsyNum)\n#           |\n#           0\n# , test: spike\nnot ok 9 - # path/to/examples/qunit_node.js:38\n#\n# assert.ok(ary1.length === ary2.length)\n#           |    |      |   |    |\n#           |    |      |   |    3\n#           |    |      |   [\"aaa\",\"bbb\",\"ccc\"]\n#           |    2      false\n#           [\"foo\",\"bar\"]\n#\n# [number] ary2.length\n# =\u003e 3\n# [number] ary1.length\n# =\u003e 2\n# , test: spike\nnot ok 10 - # path/to/examples/qunit_node.js:39\n#\n# assert.deepEqual(ary1, ary2)\n#                  |     |\n#                  |     [\"aaa\",\"bbb\",\"ccc\"]\n#                  [\"foo\",\"bar\"]\n# , expected: [\n#   \"aaa\",\n#   \"bbb\",\n#   \"ccc\"\n# ], got: [\n#   \"foo\",\n#   \"bar\"\n# ], test: spike\nnot ok 11 - # path/to/examples/qunit_node.js:42\n#\n# assert.ok(5 \u003c actual \u0026\u0026 actual \u003c 13)\n#             | |      |  |      |\n#             | |      |  16     false\n#             | 16     false\n#             true\n# , test: spike\nnot ok 12 - # path/to/examples/qunit_node.js:45\n#\n# assert.ok(5 \u003c actual \u0026\u0026 actual \u003c 13)\n#             | |      |\n#             | 4      false\n#             false\n# , test: spike\nnot ok 13 - # path/to/examples/qunit_node.js:48\n#\n# assert.ok(actual \u003c 5 || 13 \u003c actual)\n#           |      |   |     | |\n#           |      |   |     | 10\n#           |      |   false false\n#           10     false\n# , test: spike\nnot ok 14 - # path/to/examples/qunit_node.js:58\n#\n# assert.ok(foo.bar.baz)\n#           |   |   |\n#           |   |   false\n#           |   Object{baz:false}\n#           Object{bar:#Object#}\n# , test: spike\nnot ok 15 - # path/to/examples/qunit_node.js:59\n#\n# assert.ok(foo['bar'].baz)\n#           |  |       |\n#           |  |       false\n#           |  Object{baz:false}\n#           Object{bar:#Object#}\n# , test: spike\nnot ok 16 - # path/to/examples/qunit_node.js:60\n#\n# assert.ok(foo[propName]['baz'])\n#           |  ||        |\n#           |  |\"bar\"    false\n#           |  Object{baz:false}\n#           Object{bar:#Object#}\n# , test: spike\nnot ok 17 - # path/to/examples/qunit_node.js:64\n#\n# assert.ok(!truth)\n#           ||\n#           |true\n#           false\n# , test: spike\nnot ok 18 - # path/to/examples/qunit_node.js:68\n#\n# assert.ok(func())\n#           |\n#           false\n# , test: spike\nnot ok 19 - # path/to/examples/qunit_node.js:76\n#\n# assert.ok(obj.age())\n#           |   |\n#           |   0\n#           Object{age:#function#}\n# , test: spike\nnot ok 20 - # path/to/examples/qunit_node.js:83\n#\n# assert.ok(isFalsy(positiveInt))\n#           |       |\n#           false   50\n# , test: spike\nnot ok 21 - # path/to/examples/qunit_node.js:94\n#\n# assert.ok(sum(one, two, three) === seven)\n#           |   |    |    |      |   |\n#           |   |    |    |      |   7\n#           6   1    2    3      false\n#\n# [number] seven\n# =\u003e 7\n# [number] sum(one, two, three)\n# =\u003e 6\n# , test: spike\nnot ok 22 - # path/to/examples/qunit_node.js:95\n#\n# assert.ok(sum(sum(one, two), three) === sum(sum(two, three), seven))\n#           |   |   |    |     |      |   |   |   |    |       |\n#           |   |   |    |     |      |   12  5   2    3       7\n#           6   3   1    2     3      false\n#\n# [number] sum(sum(two, three), seven)\n# =\u003e 12\n# [number] sum(sum(one, two), three)\n# =\u003e 6\n# , test: spike\nnot ok 23 - # path/to/examples/qunit_node.js:96\n#\n# assert.ok(three * (seven * ten) === three)\n#           |     |  |     | |    |   |\n#           |     |  |     | |    |   3\n#           |     |  |     | 10   false\n#           |     |  7     70\n#           3     210\n#\n# [number] three\n# =\u003e 3\n# [number] three * (seven * ten)\n# =\u003e 210\n# , test: spike\nnot ok 24 - # path/to/examples/qunit_node.js:110\n#\n# assert.ok(math.calc.sum(one, two, three) === seven)\n#           |    |    |   |    |    |      |   |\n#           |    |    |   |    |    |      |   7\n#           |    |    6   1    2    3      false\n#           |    Object{sum:#function#}\n#           Object{calc:#Object#}\n#\n# [number] seven\n# =\u003e 7\n# [number] math.calc.sum(one, two, three)\n# =\u003e 6\n# , test: spike\n1..24\n```\n\nHave fun!\n\n\n[power-assert-url]: https://github.com/power-assert-js/power-assert\n[power-assert-banner]: https://raw.githubusercontent.com/power-assert-js/power-assert-js-logo/master/banner/banner-official-fullcolor.png\n\n[npm-url]: https://www.npmjs.com/package/power-assert\n[npm-image]: https://badge.fury.io/js/power-assert.svg\n\n[bower-url]: https://badge.fury.io/bo/power-assert\n[bower-image]: https://badge.fury.io/bo/power-assert.svg\n\n[travis-url]: https://travis-ci.org/power-assert-js/power-assert\n[travis-image]: https://secure.travis-ci.org/power-assert-js/power-assert.svg?branch=master\n\n[license-url]: https://github.com/power-assert-js/power-assert/blob/master/MIT-LICENSE.txt\n[license-image]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat\n","funding_links":[],"categories":["Packages","JavaScript","Repository","包","目录","Testing","Number"],"sub_categories":["Testing","测试","测试相关"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpower-assert-js%2Fpower-assert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpower-assert-js%2Fpower-assert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpower-assert-js%2Fpower-assert/lists"}