{"id":23002667,"url":"https://github.com/treedomtrees/tap-data-provider","last_synced_at":"2025-04-02T14:21:19.786Z","repository":{"id":169711396,"uuid":"643992888","full_name":"treedomtrees/tap-data-provider","owner":"treedomtrees","description":"Extends node-tap with a new tests assertion and introduces the concept of \"DataProvider\" in tests.","archived":false,"fork":false,"pushed_at":"2023-09-07T16:04:54.000Z","size":171,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-09T11:36:09.912Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/treedomtrees.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://www.treedom.net/en/organization/treedom/event/treedom-open-source?utm_source=github"]}},"created_at":"2023-05-22T15:22:37.000Z","updated_at":"2023-05-22T15:53:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"cdb9f2dd-e920-4bfb-b96d-b9a449a6bdd0","html_url":"https://github.com/treedomtrees/tap-data-provider","commit_stats":null,"previous_names":["treedomtrees/tap-data-provider"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treedomtrees%2Ftap-data-provider","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treedomtrees%2Ftap-data-provider/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treedomtrees%2Ftap-data-provider/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/treedomtrees%2Ftap-data-provider/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/treedomtrees","download_url":"https://codeload.github.com/treedomtrees/tap-data-provider/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246828477,"owners_count":20840474,"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":[],"created_at":"2024-12-15T07:11:58.082Z","updated_at":"2025-04-02T14:21:19.765Z","avatar_url":"https://github.com/treedomtrees.png","language":"JavaScript","funding_links":["https://www.treedom.net/en/organization/treedom/event/treedom-open-source?utm_source=github"],"categories":[],"sub_categories":[],"readme":"# tap-data-provider\n\nExtends [node-tap](https://node-tap.org/) with a new tests assertion and introduces the concept of \"DataProvider\" in tests.\n\n## Install\n\n```shell\nnpm install @treedom/tap-data-provider -D\n```\n\n## Usage\nThe module will add a new ```tests``` method which accept the following params:\n- **name**: The name of test, same of the original tap test function\n- **dataSource**: The data with which the tests will be executed. \n- **fn**: A function similar to the original one, but which receives also a variable number of params based on data source elements\n\n### Datasource\nDatasource can be provided in form of array or **data provider function**. In case of function it must return an array. \n\nThe data source array element can be of type\n**array** or **object**. \n\nIn case of array element, the first value will be the _input_ params of the callback function, and the second value will be the _expected_\n\nIn case of object element it should have the propery _input_ and _expected_ that will be mapped in the relative params of the callback function\n\n\n```javascript\nconst tap = require('tap')\nconst tdp = require('@treedom/tap-data-provider')\ntdp(tap)\n\nfunction sum(number1, number2) {\n  return number1 + number2\n}\n\n// Data source given as array\nconst datasource = [\n  { input: {value_1: 1, value_2: 2}, expected: 3},\n  { input: {value_1: 3, value_2: 2}, expected: 5},\n]\ntap.tests('sum should return right values', datasource, (tap, {value_1, value_2}, expected) =\u003e {\n  tap.equal(sum(value_1, value_2), expected)\n  tap.end()\n})\n\n// Data source given as provider function\nfunction sumDataProvider() {\n  return [\n    [{value_1: 1, value_2: 2}, 3],\n    [{value_1: 3, value_2: 2}, 5],\n  ]\n}\ntap.tests('sum should return right values', sumDataProvider, (tap, {value_1, value_2}, expected) =\u003e {\n  tap.equal(sum(value_1, value_2), expected)\n  tap.end()\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreedomtrees%2Ftap-data-provider","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftreedomtrees%2Ftap-data-provider","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftreedomtrees%2Ftap-data-provider/lists"}