{"_id":"it-each","_rev":"19-a28a447940992d8327af13be45fe403d","name":"it-each","description":"Enable basic async test looping in Mocha","dist-tags":{"latest":"0.5.0"},"versions":{"0.1.0":{"name":"it-each","version":"0.1.0","description":"Enable basic async test looping in Mocha","author":{"name":"Isaac Whitfield","email":"iwhitfield@appcelerator.com"},"repository":{"type":"git","url":"http://github.com/iwhitfield/it.each.git"},"bugs":{"url":"http://github.com/iwhitfield/it.each/issues"},"license":"MIT","keywords":["mocha","async","iterable"],"dependencies":{"async":"*","mocha":"*"},"homepage":"https://github.com/iwhitfield/it.each","_id":"it-each@0.1.0","scripts":{},"_shasum":"381a40f8ec32cb2f958a5f73de9fbc99e5a186d6","_from":".","_npmVersion":"1.4.13","_npmUser":{"name":"iwhitfield","email":"iwhitfield@appcelerator.com"},"maintainers":[{"name":"iwhitfield","email":"iwhitfield@appcelerator.com"}],"dist":{"shasum":"381a40f8ec32cb2f958a5f73de9fbc99e5a186d6","tarball":"https://registry.npmjs.org/it-each/-/it-each-0.1.0.tgz","integrity":"sha512-0ZKFoWxzR9PK/qo2AZ5CIv0oO2NLH3xgO01qEwFc8G+SsBoqHwafM1v7QWJqYiD987q4psoZMXsY2osLiVsiZw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBtbDtDBuRhkktQJfBGNtTHjZUReUVQLVYjlYVhkSQbpAiBCybkSuRF66eGmUAbKXP2J/wnkzbttJ0RbDR5JoaLYiQ=="}]},"directories":{}},"0.1.1":{"name":"it-each","version":"0.1.1","description":"Enable basic async test looping in Mocha","author":{"name":"Isaac Whitfield","email":"iwhitfield@appcelerator.com"},"repository":{"type":"git","url":"http://github.com/iwhitfield/it.each.git"},"bugs":{"url":"http://github.com/iwhitfield/it.each/issues"},"license":"MIT","keywords":["mocha","async","iterable"],"dependencies":{"async":"*","mocha":"*"},"gitHead":"318fd6f6726430d8bf496f4bb9d56ca0e25428c9","homepage":"https://github.com/iwhitfield/it.each","_id":"it-each@0.1.1","scripts":{},"_shasum":"65847377f73677bd1640aa9f48f8b291315e62a4","_from":".","_npmVersion":"1.4.13","_npmUser":{"name":"iwhitfield","email":"iwhitfield@appcelerator.com"},"maintainers":[{"name":"iwhitfield","email":"iwhitfield@appcelerator.com"}],"dist":{"shasum":"65847377f73677bd1640aa9f48f8b291315e62a4","tarball":"https://registry.npmjs.org/it-each/-/it-each-0.1.1.tgz","integrity":"sha512-m9eKfUSHT11AVQ4LWWs5fvirdnktoJnYQEfQQ6XBCjhSPgHifCoxNYszqJx7o7bIa52pIFxO8kqHVczH6KrgcQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDO2cPTabtdX/WjdA86PxQ2m3PiA1yIcy/DMetTC7AgJAiBMzlCwEu2i87W+uEJI04SadbZTU+xp1hgd31vwIAkDmA=="}]},"directories":{}},"0.2.0":{"name":"it-each","version":"0.2.0","description":"Enable basic async test looping in Mocha","author":{"name":"Isaac Whitfield","email":"iwhitfield@appcelerator.com"},"repository":{"type":"git","url":"http://github.com/iwhitfield/it.each.git"},"bugs":{"url":"http://github.com/iwhitfield/it.each/issues"},"license":"MIT","keywords":["mocha","async","iterable"],"dependencies":{"async":"*"},"devDependencies":{"mocha":"*"},"gitHead":"8b3e24ff0c87d9a7052c1a461620cbecdd1ba9c8","homepage":"https://github.com/iwhitfield/it.each","_id":"it-each@0.2.0","scripts":{},"_shasum":"c3ebc0376a05c4764e91f81e6827fde11d4d98f1","_from":".","_npmVersion":"2.1.4","_nodeVersion":"0.10.33","_npmUser":{"name":"iwhitfield","email":"iwhitfield@appcelerator.com"},"maintainers":[{"name":"iwhitfield","email":"iwhitfield@appcelerator.com"}],"dist":{"shasum":"c3ebc0376a05c4764e91f81e6827fde11d4d98f1","tarball":"https://registry.npmjs.org/it-each/-/it-each-0.2.0.tgz","integrity":"sha512-534rcWrbHqY8oi6sz/GdfeIkZ/0hgPzRDnvOBfWLWXqk20CsQUp2O87GD5m0en+JxpeeC+he4f8m/v5qtNzNEw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCC2JnaOvPxQ7Fy69wV2VLR4gg8WbkZkXOFb8yIrXO1OwIhALia21GRsYQr74mXoepwKygTJsYFBUMwA3MKWIKNDqs5"}]},"directories":{}},"0.3.0":{"name":"it-each","version":"0.3.0","description":"Enable basic async test looping in Mocha","author":{"name":"Isaac Whitfield","email":"iwhitfield@appcelerator.com"},"repository":{"type":"git","url":"http://github.com/iwhitfield/it.each.git"},"bugs":{"url":"http://github.com/iwhitfield/it.each/issues"},"license":"MIT","keywords":["async","mocha","iterable"],"devDependencies":{"blanket":"1.1.6","coveralls":"2.11.2","mocha":"2.1.0","mocha-lcov-reporter":"0.0.1","should":"5.0.0"},"scripts":{"coverage":"mocha -r blanket -R html-cov test > coverage.html","test":"mocha test"},"config":{"blanket":{"data-cover-never":["node_modules","test"],"pattern":["lib/it.each.js","lib/util.js"]}},"gitHead":"c82733cde11c412fdffdd1a358661895c2b3b3af","homepage":"https://github.com/iwhitfield/it.each","_id":"it-each@0.3.0","_shasum":"1af0b9bffc2fb3971715e40948948702cb5f78ac","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"iwhitfield","email":"iwhitfield@appcelerator.com"},"maintainers":[{"name":"iwhitfield","email":"iwhitfield@appcelerator.com"}],"dist":{"shasum":"1af0b9bffc2fb3971715e40948948702cb5f78ac","tarball":"https://registry.npmjs.org/it-each/-/it-each-0.3.0.tgz","integrity":"sha512-HUdenXmj2iDBiEy8jifDDZhdTrBHNyuhUM2l+h7yAtWI903RRMPtOqt5MlMMrnaPK0bIw2EjZ1BnaTxK/8qmXA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBUs9ShZfDHtPmkRVatQ++olB8wuRyZDLgX0zsovScYdAiEA8ikjrH4t0+3KH+sOkzKy+sZEMoCo9ufMdubX+XFfMJY="}]},"directories":{}},"0.3.1":{"name":"it-each","version":"0.3.1","description":"Enable basic async test looping in Mocha","author":{"name":"Isaac Whitfield","email":"iwhitfield@appcelerator.com"},"repository":{"type":"git","url":"http://github.com/iwhitfield/it.each.git"},"bugs":{"url":"http://github.com/iwhitfield/it.each/issues"},"license":"MIT","keywords":["async","mocha","iterable"],"dependencies":{"dot-notes":"1.1.1"},"devDependencies":{"blanket":"1.1.6","codeclimate-test-reporter":"0.0.4","mocha":"2.1.0","mocha-lcov-reporter":"0.0.1","should":"5.0.0"},"scripts":{"coverage":"mocha -r blanket -R html-cov test","lcov":"mocha -r blanket -R mocha-lcov-reporter","test":"mocha test"},"config":{"blanket":{"data-cover-never":["node_modules","test"],"pattern":["lib/it.each.js","lib/util.js"]}},"gitHead":"daef2ed84887b2d305058368e9fb6daab5ca5f9c","homepage":"https://github.com/iwhitfield/it.each","_id":"it-each@0.3.1","_shasum":"44fa1cbd26b6c79d3250cb6da6ddc3f37947e114","_from":".","_npmVersion":"2.6.1","_nodeVersion":"0.10.36","_npmUser":{"name":"iwhitfield","email":"iwhitfield@appcelerator.com"},"maintainers":[{"name":"iwhitfield","email":"iwhitfield@appcelerator.com"}],"dist":{"shasum":"44fa1cbd26b6c79d3250cb6da6ddc3f37947e114","tarball":"https://registry.npmjs.org/it-each/-/it-each-0.3.1.tgz","integrity":"sha512-/AbNPVrVtFYb2cglzF5C8BMwvXy+RKFKEBkGAZ6pi/Z7n33KDVXe8+uugLHdJ7E0ueHG2+g/dQK5CPowQj/kTA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGW+QpFbUI9vvzCdejYEsMT9n1GS85h7LIAldanbnYQnAiEAkce/mzYulBK17O+EFsTadmZQI7KODCBl2Ua7J+3SDEs="}]},"directories":{}},"0.4.0":{"name":"it-each","version":"0.4.0","description":"Enable basic async test looping in Mocha","author":{"name":"Isaac Whitfield","email":"iw@whitfin.io"},"repository":{"type":"git","url":"git+ssh://git@github.com/whitfin/it.each.git"},"bugs":{"url":"http://github.com/whitfin/it.each/issues"},"license":"MIT","keywords":["async","mocha","iterable"],"dependencies":{"dot-notes":"3.1.1"},"devDependencies":{"mocha":"5.2.0","should":"13.2.1"},"scripts":{"test":"mocha test"},"gitHead":"c6f90d17dc8aa3134c0d71126c36940c6b64af07","homepage":"https://github.com/whitfin/it.each#readme","_id":"it-each@0.4.0","_npmVersion":"5.6.0","_nodeVersion":"8.11.1","_npmUser":{"name":"whitfin","email":"iw@whitfin.io"},"dist":{"integrity":"sha512-fbOxSUiOByQnkgoFUEKPfzAuoUZ0mQRAXdWWsfI53gMJZ2oyhPcJBOCFx8yuMM36yP6OUUL3LgilYEqBiSACmQ==","shasum":"d7bd0538766471e77e0d22034ab91c252ca834c4","tarball":"https://registry.npmjs.org/it-each/-/it-each-0.4.0.tgz","fileCount":9,"unpackedSize":18933,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbSmQJCRA9TVsSAnZWagAAtyIP/225/Ss6gT1FqyiYdYuJ\nLUDNsbn6pbI4WS0Gr/0ACX7URlvb3b2Y793f7z2wNyJ0Z3HDHc096SH6dLSk\nsfZ1592ICdrQzrQ4YRS/eOejXEgUYX3znwGwKlmCamt2ZNo+8vJ90/9YoLNU\nvwvb35LIrLdOoAajqsHKfq+XaO0cDrKkMQznMLuPFcYBm1YVTzqtO4D7LzRX\niiKQPO3Xhq1xFo56+86XJVMfJpLYxC864t36lBpSHJdFeYXs6/RQYLGRZgtk\ngXU8eaHszJ6Fa+tOYIwRPqMFxxkYLesM0xfqCcNVAGpaTJEDoHaVesFD6gTw\nf/xLMmUoNWNfeL+JCTKoXoZTZvrsEqJ6OCD/RXWZ6/yQmSZihytOUPqFi10m\nGv7+PDqxgvsl3978QO7/1pjp4eFwz6Unstu0NIM7yaT5No27gV8UbVUWbb46\n++FQRgzOKYKgA1rU0b2+6G44fNGOkEdyOkmEGAAAY2iZbuTI6JrWgrrZvsf/\njB+XQ7VoXmqS528bz5GMcCyjisAV0Z0pdl46n702SW/8ADzlDd6B4mMD5pRv\n82MhfqtXqq9hTTnXZmFoUI+90SFOQphq7fMbrkb6jsTiNz9IGtuSrA4saKXA\nRZZ7MrcGSUoU0d61mP4OH6ioYnSSjSBSebbAP7QS3WK1D6RN4Nz0WL8BVArT\nb0JZ\r\n=qAdh\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD45SPd5gHJOXje5jR2XS9PwO6IQXrXaefecTHlXf8s6QIgWJt6wyCuGIv0AOD1xeJ0I94NgUP50MKdoD4yRzrmw4k="}]},"maintainers":[{"email":"isaac@whitfin.io","name":"whitfin"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/it-each_0.4.0_1531601929347_0.07521906614745966"},"_hasShrinkwrap":false},"0.5.0":{"name":"it-each","version":"0.5.0","description":"Enable basic async test looping in Mocha","author":{"name":"Isaac Whitfield","email":"iw@whitfin.io"},"repository":{"type":"git","url":"git+ssh://git@github.com/whitfin/it.each.git"},"bugs":{"url":"http://github.com/whitfin/it.each/issues"},"license":"MIT","keywords":["async","mocha","iterable"],"scripts":{"lint":"eslint lib/* test/*.js *.js","test":"mocha test"},"dependencies":{"dot-notes":"^3.2.2"},"devDependencies":{"eslint":"^8.53.0","mocha":"^10.2.0","should":"^13.2.3"},"gitHead":"c4dcedc82c5c07c2e28b83708bc08e4a27af8b5b","homepage":"https://github.com/whitfin/it.each#readme","_id":"it-each@0.5.0","_nodeVersion":"20.4.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-wBaPbvhzI0Wecs4aO0iAbp6IPXac0N9/vUCS/HmUzO8znqFLGIbUcaJ/4Ew/UlyrcIGgMWIBEXUtEQxLSnSllA==","shasum":"93ba1786bda04ae0949a59acf75ff31c16f7a0c4","tarball":"https://registry.npmjs.org/it-each/-/it-each-0.5.0.tgz","fileCount":6,"unpackedSize":11855,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCpfw7vwpkoB2ppjk+1LCimiexnqEtboTnhOmGmnN36uAIgROPPQK5Vxr/w0j3h1qGZ/2O6mTFtvOhMZLnb771HBAM="}]},"_npmUser":{"name":"whitfin","email":"iw@whitfin.io"},"directories":{},"maintainers":[{"name":"whitfin","email":"iw@whitfin.io"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/it-each_0.5.0_1699950548604_0.24461207931467577"},"_hasShrinkwrap":false}},"readme":"# it.each\n\n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/whitfin/it.each/ci.yml?branch=main)](https://github.com/whitfin/it.each/actions) [![Published Version](https://img.shields.io/npm/v/it-each.svg)](https://npmjs.com/package/it-each) [![Published Downloads](https://img.shields.io/npm/dt/it-each)](https://npmjs.com/package/it-each)\n\n- [Setup](#setup)\n- [Integration](#integration)\n- [How Does It Work?](#example-usage)\n- [Context](#context)\n- [Synchronicity](#synchronicity)\n- [Issues](#issues)\n\nThis module provides a way to use asynchronous loops alongside Mocha via a simple extension of the `it` handler. This works as of Mocha v2.1.0, and I would imagine it would continue to work in future against all versions, but no promises.\n\nThe current version is below v1.0.0 so the potential does exist for breaking changes, however this will be avoided where possible. The reason this module remains below the v1.0.0 tag is because there is no clear roadmap; meaning implementation may have to change at some point.\n\n### Setup ###\n\n`it.each` is available on [npm](https://www.npmjs.com/package/it-each), so simply install it:\n\n```\n$ npm install it-each\n```\n\n### Integration ###\n\nThe idea of this method is to stay simple. Simply require in this module **after** you have instantiated Mocha (or any time if you're running with the mocha command line), and before you use an `it.each` loop. If you wish to have a separate test listing for each iteration, include an options object containining `testPerIteration` set to `true`.\n\n```\nrequire('it-each')();\n\nrequire('it-each')({ testPerIteration: true });\n```\n\nThis will enable `it.each()` for use in your testing. You are able to call the module again if you want to update any settings, for example if one suite requires a test per iteration and a different suite does not.\n\nIf testPerIteration is either unset or `false`, the `timeout` and `slow` values of the tests are multiplied by the number of elements in the array in order to avoid hitting Mocha timeouts unnecessarily. In addition, the test name is appended with a tracking value (`- 1/X`) to provide additional context should a failure occur. This ensures that common code per tests does not remove the ability to calculate which set of values is causing an issue.\n\n### Example Usage ###\n\nThere are two different ways you can use `it.each`; with dynamic titles, and with static titles. Dynamic is better if you're intending to track your tests through the loop, whereas static is very similar to just putting an async loop inside your call to the usual `it`. There are examples inside the `test/` directory, with both methods of titling - however here are the signatures you can use, and an explanation of how it works:\n\n**Dynamic**\n\n```\nit.each(iterable, title, fields, process);\n```\n\nHere is what the above translates to:\n\n```\n* iterable - the array you're going to iterate through\n* title    - the title your tests will use, in a formattable way. E.g. \"Test #%d\"\n* fields   - an array of keys to extract from each element to use to format the above title\n* process  - the processing to run on each element in the iterable\n```\n\nYour `process` function will be provided with two parameters as follows:\n\n```\nit.each([], \"My test\", function(element, next){\n    // where element is the current array index value\n});\n```\nPlease note that you only need call and use `next` if your function is asynchronous. If your function is synchronous, you can safely omit it. Be aware though, if `next` is specified in your parameters, you **must** call it to continue.\n\n\nHere is an example of a title/fields combination.\n\n```\nvar examples = [{ 'example' : 1, 'nested.example' : 2, 'inner' : { 'nest' : 3 } }];\n\n// Your test title will extract the fields and result in: 'Example 1 with key 2 and nest 3'\nit.each(examples, 'Example %s with key %s and nest %s', ['example', 'nested.example', 'inner.nest'], ...);\n```\n\nThere are two reserved 'keywords' you can pass to the fields array, `x` and `element`. In this case, `x` will represent the iteration number the current test is on (starting at 0, so as to keep in track with the array), and `element` will be the element in the current processing loop.\n\nAs of v0.3.1, full forms of dot notation are supported in keys, by way of [dot-notes](https://www.npmjs.com/package/dot-notes). Feel free to provide special keys and array indices for use in formatting.\n\n**Static**\n\nStatic is basically the same as just calling `it` over and over again with different values in the closure. This provides an easy shorthand to create tests from existing values. The signature of static titling is the same as that of dynamic, except with the omission of the `fields` parameter.\n\n**Skip**\n\nWhen developing a test it is sometimes useful to be able to skip all other tests in the suite. This may be done by using `it.each.skip`.\n\n### Context ###\n\nAs of version v0.3.0 the context of the `it` is provided to the executed function in order to allow setting both `slow` and `timeout` from within the executed function. This is a potentially breaking change, however I doubt anybody was using `this` in the current version since it provided no additional context.\n\n### Synchronicity ###\n\nAgain, as of v0.3.0 you now have the ability to execute a loop synchronously or asynchronously. Previously there was an unstated requirement to call the callback provided to the executed function, which does not fit with the Mocha stylings. In order to resolve this, your function will be run synchronously unless you ask for the callback to be passed in (e.g. by declaring it in your parameters). Should the callback be provided to your function, it must be called in order to finish the test.\n\n### Issues ###\n\nIf you find any issues inside this module, feel free to open an issue [here](https://github.com/whitfin/it.each/issues \"it.each Issues\").\n","maintainers":[{"name":"whitfin","email":"iw@whitfin.io"}],"time":{"modified":"2023-11-14T08:29:09.060Z","created":"2014-06-09T17:22:43.348Z","0.1.0":"2014-06-09T17:22:43.348Z","0.1.1":"2014-06-11T16:44:33.168Z","0.2.0":"2014-11-27T18:01:12.808Z","0.3.0":"2015-02-20T03:14:55.222Z","0.3.1":"2015-03-22T05:32:00.182Z","0.4.0":"2018-07-14T20:58:49.450Z","0.5.0":"2023-11-14T08:29:08.885Z"},"homepage":"https://github.com/whitfin/it.each#readme","keywords":["async","mocha","iterable"],"repository":{"type":"git","url":"git+ssh://git@github.com/whitfin/it.each.git"},"author":{"name":"Isaac Whitfield","email":"iw@whitfin.io"},"bugs":{"url":"http://github.com/whitfin/it.each/issues"},"license":"MIT","readmeFilename":"README.md"}