{"_id":"@bahmutov/data-driven","_rev":"4175165","name":"@bahmutov/data-driven","description":"Transforms BDD input into data-driven snapshot","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"bahmutov","email":"gleb.bahmutov@gmail.com"}],"time":{"modified":"2026-03-01T21:29:31.000Z","created":"2017-09-03T05:20:27.716Z","1.0.0":"2017-09-03T05:20:27.716Z"},"users":{},"author":{"name":"Gleb Bahmutov","email":"gleb.bahmutov@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/bahmutov/data-driven.git"},"versions":{"1.0.0":{"name":"@bahmutov/data-driven","description":"Transforms BDD input into data-driven snapshot","version":"1.0.0","author":{"name":"Gleb Bahmutov","email":"gleb.bahmutov@gmail.com"},"bugs":{"url":"https://github.com/bahmutov/data-driven/issues"},"config":{"pre-git":{"commit-msg":"simple","pre-commit":["npm prune","npm run deps","npm test","git add src/*.js","npm run ban"],"pre-push":["npm run secure","npm run license","npm run ban -- --all","npm run size"],"post-commit":[],"post-merge":[]}},"engines":{"node":">=6"},"files":["src/*.js","!src/*-spec.js"],"homepage":"https://github.com/bahmutov/data-driven#readme","keywords":["bdd","data-driven","mocha","testing","utility"],"license":"MIT","main":"src/","publishConfig":{"registry":"http://registry.npmjs.org/"},"repository":{"type":"git","url":"git+https://github.com/bahmutov/data-driven.git"},"scripts":{"ban":"ban","deps":"deps-ok && dependency-check --no-dev .","issues":"git-issues","license":"license-checker --production --onlyunknown --csv","lint":"standard --verbose --fix src/*.js","prelint":"npm run pretty","pretest":"npm run lint","pretty":"prettier-standard 'src/*.js'","secure":"nsp check","size":"t=\"$(npm pack .)\"; wc -c \"${t}\"; tar tvf \"${t}\"; rm \"${t}\";","test":"npm run unit","unit":"mocha src/*-spec.js","semantic-release":"semantic-release pre && npm publish --access public && semantic-release post"},"release":{"analyzeCommits":"simple-commit-message","generateNotes":"github-post-release","verifyRelease":{"path":"dont-crack","test-against":["https://github.com/bahmutov/snap-shot","https://github.com/bahmutov/snap-shot-it"]}},"devDependencies":{"ban-sensitive-files":"1.9.0","dependency-check":"2.9.1","deps-ok":"1.2.1","dont-crack":"1.2.1","git-issues":"1.3.1","github-post-release":"1.13.1","license-checker":"14.0.0","mocha":"3.5.0","nsp":"2.7.0","pre-git":"3.15.3","prettier-standard":"6.0.0","ramda":"0.24.1","semantic-release":"7.0.2","simple-commit-message":"3.3.1","standard":"10.0.3"},"dependencies":{"check-more-types":"2.24.0","lazy-ass":"1.6.0"},"gitHead":"157efbda636da7fe2534b627e1c2a1329f84bd8c","_id":"@bahmutov/data-driven@1.0.0","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"bahmutov","email":"gleb.bahmutov@gmail.com"},"dist":{"shasum":"6897061cd61a0afc26a7079527bfbb1073b4228a","size":3035,"noattachment":false,"key":"/@bahmutov/data-driven/-/@bahmutov/data-driven-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@bahmutov/data-driven/download/@bahmutov/data-driven-1.0.0.tgz"},"maintainers":[{"name":"bahmutov","email":"gleb.bahmutov@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/data-driven-1.0.0.tgz_1504416026755_0.15712928352877498"},"directories":{},"publish_time":1504416027716,"_hasShrinkwrap":false,"_cnpm_publish_time":1504416027716,"_cnpmcore_publish_time":"2021-12-17T03:41:55.896Z"}},"readme":"# @bahmutov/data-driven\n\n> Transforms BDD input into data-driven snapshot\n\n[![NPM][npm-icon] ][npm-url]\n\n[![Build status][ci-image] ][ci-url]\n[![semantic-release][semantic-image] ][semantic-url]\n[![js-standard-style][standard-image]][standard-url]\n\n## Install\n\nRequires [Node](https://nodejs.org/en/) version 6 or above.\n\n```sh\nnpm install --save @bahmutov/data-driven\n```\n\n## Use\n\nData-driven snapshot testing takes as an input a pure function and a bunch of arguments.\n\n```js\n// is this data-driven test? for example\nsnapshot(isPrime, 1, 2, 3, 4, 5)\n// or\nsnapshot(add, [1, 2], [-5, 5], [4, 6])\n```\n\nThis module detects the above cases, and also has a utility method to compute the expected\nresult. From snap-shot frameworks, like [snap-shot][snap-shot] and [snap-shot-it][snap-shot-it]\nwhen getting a value check if user wants data-driven value, and if yes, compute it.\n\n```js\nconst {isDataDriven, dataDriven} = require('@bahmutov/data-driven')\nfunction snapshot(what) {\n  if (isDataDriven(arguments)) {\n    what = dataDriven(what, Array.from(arguments).slice(1))\n  }\n}\n```\n\nA typical value transformation would be\n\n```js\nconst results = dataDriven(isPrime, [1, 2, 3])\n/* results is\n{\n  name: 'isPrime',\n  behavior: [\n    {\n      given: 1,\n      expect: false\n    },\n    {\n      given: 2,\n      expect: true\n    },\n    {\n      given: 3,\n      expect: true\n    }\n  ]\n}\n*/\n```\n\n[snap-shot]: https://github.com/bahmutov/snap-shot\n[snap-shot-it]: https://github.com/bahmutov/snap-shot-it\n\n### Small print\n\nAuthor: Gleb Bahmutov &lt;gleb.bahmutov@gmail.com&gt; &copy; 2017\n\n* [@bahmutov](https://twitter.com/bahmutov)\n* [glebbahmutov.com](https://glebbahmutov.com)\n* [blog](https://glebbahmutov.com/blog)\n\nLicense: MIT - do anything with the code, but don't blame me if it does not work.\n\nSupport: if you find any problems with this module, email / tweet /\n[open issue](https://github.com/bahmutov/data-driven/issues) on Github\n\n## MIT License\n\nCopyright (c) 2017 Gleb Bahmutov &lt;gleb.bahmutov@gmail.com&gt;\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the \"Software\"), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.\n\n[npm-icon]: https://nodei.co/npm/@bahmutov/data-driven.svg?downloads=true\n[npm-url]: https://npmjs.org/package/@bahmutov/data-driven\n[ci-image]: https://travis-ci.org/bahmutov/data-driven.svg?branch=master\n[ci-url]: https://travis-ci.org/bahmutov/data-driven\n[semantic-image]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\n[semantic-url]: https://github.com/semantic-release/semantic-release\n[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg\n[standard-url]: http://standardjs.com/\n","_attachments":{},"homepage":"https://github.com/bahmutov/data-driven#readme","bugs":{"url":"https://github.com/bahmutov/data-driven/issues"},"license":"MIT"}