{"id":21467924,"url":"https://github.com/danr/proptest","last_synced_at":"2025-09-04T17:37:06.146Z","repository":{"id":48020468,"uuid":"118682059","full_name":"danr/proptest","owner":"danr","description":"Property-based testing a'la QuickCheck for TypeScript and JavaScript","archived":false,"fork":false,"pushed_at":"2021-08-10T22:51:37.000Z","size":167,"stargazers_count":20,"open_issues_count":6,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-14T00:12:52.769Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/danr.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}},"created_at":"2018-01-23T23:04:57.000Z","updated_at":"2024-04-15T10:03:43.000Z","dependencies_parsed_at":"2022-08-12T16:50:43.735Z","dependency_job_id":null,"html_url":"https://github.com/danr/proptest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danr%2Fproptest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danr%2Fproptest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danr%2Fproptest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danr%2Fproptest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danr","download_url":"https://codeload.github.com/danr/proptest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226018958,"owners_count":17560751,"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-11-23T08:20:35.411Z","updated_at":"2024-11-23T08:20:36.905Z","avatar_url":"https://github.com/danr.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Property-based testing for TypeScript and JavaScript\n\nThis is an implementation of property-based testing a'la QuickCheck for TypeScript.\nIt works with plain JavaScript and languages like CoffeeScript too.\n\nShrinking is done by generating lazy rose trees of values directly.\nThis means that you can map and chain generators and get correct\nshrinking functions \"for free\". This is a deviation from the original\nHaskell library but works well in languages without typeclasses.\n(The same approach is taken in other implementations\nsuch as Hedgehog for Haskell, Hypothesis for Python and test.check for Clojure)\n\n#### Usage with mocha and jest\n\n```typescript\nimport * as QC from 'proptest'\nconst property = QC.createProperty(it)\n\ndescribe('f', () =\u003e {\n  property(\n    'is commutative',\n    QC.nat.two(),\n    ([x, y]) =\u003e (expect(f(x, y)).toEqual(f(y, x)), true)\n  )\n})\n```\n\n(to be improved; remove returning a boolean: [discussion](https://github.com/danr/proptest/pull/6#issuecomment-370249397))\n\n#### Usage with tape\n\n```typescript\nimport * as QC from 'proptest'\nconst check = QC.adaptTape(test)\n\ncheck('f commutative', QC.nat.two(), ([x, y]) =\u003e f(x, y) === f(y, x))\n```\n\n#### Usage with AVA\n\n```typescript\nimport * as QC from 'proptest'\ntest('f commutative', t =\u003e {\n  t.true(QC.stdoutForall(QC.nat.two(), ([x, y]) =\u003e f(x, y) === f(y, x)))\n})\n```\n\n(to be improved, also see [ava#1692](https://github.com/avajs/ava/issues/1692))\n\n#### Usage without a library as an assertion\n\n```typescript\nimport * as QC from 'proptest'\nQC.assertForall(QC.nat.two(), ([x, y]) =\u003e f(x, y) === f(y, x))\n```\n\n\nThe API exports a function `search` which returns `{'ok': true}` if the property\npassed or `{'ok': false}` and the counterexample (or other information) if it did not.\n\n### Installation\n\nYou can grab it from npm:\n\n```\nnpm i -D proptest\n```\n\nYou may use yarn:\n\n```\nyarn add --dev proptest\n```\n\n\n### Contributors\n\n* Simon Friis Vindum [@paldepind](https://github.com/paldepind) ([commits](https://github.com/danr/proptest/commits?author=paldepind))\n\n### Ongoing discussions\n\n* Should properties return a boolean of success or just not throw an assertion? [#6](https://github.com/danr/proptest/pull/6) [#5](https://github.com/danr/proptest/issues/5)\n\n### License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanr%2Fproptest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanr%2Fproptest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanr%2Fproptest/lists"}