{"id":15612021,"url":"https://github.com/hypercubed/ava-check","last_synced_at":"2025-03-29T15:12:32.282Z","repository":{"id":66193224,"uuid":"113115947","full_name":"Hypercubed/ava-check","owner":"Hypercubed","description":null,"archived":false,"fork":false,"pushed_at":"2017-12-05T01:32:45.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-04T15:49:27.213Z","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":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Hypercubed.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-05T01:31:53.000Z","updated_at":"2017-12-05T01:32:46.000Z","dependencies_parsed_at":null,"dependency_job_id":"1f01600f-9bc8-4117-a0b6-464329c60fe6","html_url":"https://github.com/Hypercubed/ava-check","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"b175aa551555176eef19916214c58a8f8779b093"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Fava-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Fava-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Fava-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Hypercubed%2Fava-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Hypercubed","download_url":"https://codeload.github.com/Hypercubed/ava-check/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246200322,"owners_count":20739566,"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-10-03T06:21:34.814Z","updated_at":"2025-03-29T15:12:32.262Z","avatar_url":"https://github.com/Hypercubed.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Generative property testing for AVA\n===================================\n\n`ava-check` adds the generative testing power of [`testcheck-js`](https://github.com/leebyron/testcheck-js)\nto [AVA](https://github.com/avajs/ava/). This allows some of your AVA tests\nto accept arguments and ensure your tests pass not just under your contrived\ntest cases but also pass for hundreds of randomly generated test cases.\n\n\nGetting started\n---------------\n\nInstall `ava-check` using yarn.\n\n```sh\nyarn add --dev ava-check\n```\n\nOr using npm\n\n```sh\nnpm install --save-dev ava-check\n```\n\nThen include `ava-check` in your test.\n\n```js\nconst { check, gen } = require('ava-check')\n```\n\n\nExample\n-------\n\n```js\nconst test = require('ava')\nconst { check, gen } = require('ava-check')\n\ntest('addition is commutative', check(gen.int, gen.int, (t, numA, numB) =\u003e {\n  t.true(numA + numB === numB + numA)\n}));\n```\n\nThe `gen` object is provided directly by `testcheck` and defines what type of\nvalues to generate. The test will be run numerous times with randomly generated\nvalues, ensuring all expectations are met for every run. If a test expectation\nfails, then the test will re-run with \"smaller\" values until the smallest\nfailing value is found which can better help explain edge cases with your test\nand produce consistent results, despite being initially fueled by randomness.\n\nFor example, here's a test which we expect would fail:\n\n```js\nconst test = require('ava')\nconst { check, gen } = require('ava-check')\n\ntest('division is commutative', check(gen.sPosInt, gen.sPosInt, (t, numA, numB) =\u003e {\n  t.true(numA / numB === numB / numA)\n}));\n```\n\nWhen we run this test, we find the smallest failing test:\n\n```sh\n\u003e ava test\n\n  1 failed\n\n  division is commutative ( 1, 2 )\n\n  t.true(numA / numB === numB / numA)\n         |      |        |      |\n         1      2        2      1\n```\n\n\n### Options\n\nIf a test is taking a long time, needs to generate larger values, or should be\nrun with a consistent random seed, you can alter the behavior with `options`:\n\n```js\n{\n  times: number;   // the number of test cases to run. Default: 100\n  maxSize: number; // the maximum \"size\" of the test data. Default: 200\n  seed: number;    // defaults to a random value from 1 to 2^32-1.\n}\n```\n\nTo use these options with your check, include an options object before the\nargument generators.\n\n```js\ntest('runs 10 times', check({ times: 10 }, gen.posInt, (t, n) =\u003e {\n  t.true(x \u003e= 0)\n}))\n```\n\nTo learn more about property testing, or to learn about the available value\ngenerators, check out [`testcheck`](https://github.com/leebyron/testcheck-js).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypercubed%2Fava-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhypercubed%2Fava-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhypercubed%2Fava-check/lists"}