{"id":18376818,"url":"https://github.com/bbc/verify-it","last_synced_at":"2025-06-17T04:33:36.872Z","repository":{"id":57391664,"uuid":"89702444","full_name":"bbc/verify-it","owner":"bbc","description":"Randomised test property/data generation for NodeJS","archived":false,"fork":false,"pushed_at":"2025-01-17T08:59:43.000Z","size":273,"stargazers_count":5,"open_issues_count":2,"forks_count":4,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-22T06:51:12.954Z","etag":null,"topics":["data","node","nodejs","property","random","randomization","test","testing","typescript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bbc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","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-04-28T12:05:47.000Z","updated_at":"2025-01-17T08:59:44.000Z","dependencies_parsed_at":"2024-06-19T05:56:36.587Z","dependency_job_id":"f37fdb40-395f-4f33-b5b2-95ab7db29848","html_url":"https://github.com/bbc/verify-it","commit_stats":{"total_commits":94,"total_committers":5,"mean_commits":18.8,"dds":"0.12765957446808507","last_synced_commit":"27e87e4717213079787379fd9f6a95bd64fb6c5f"},"previous_names":[],"tags_count":28,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fverify-it","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fverify-it/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fverify-it/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbc%2Fverify-it/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bbc","download_url":"https://codeload.github.com/bbc/verify-it/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247074322,"owners_count":20879232,"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":["data","node","nodejs","property","random","randomization","test","testing","typescript"],"created_at":"2024-11-06T00:24:52.190Z","updated_at":"2025-04-06T20:31:37.037Z","avatar_url":"https://github.com/bbc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `verify-it`\n\n_Randomised test property/data generation for NodeJS._\n\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![Build Status](https://travis-ci.org/bbc/verify-it.svg?branch=master)](https://travis-ci.org/bbc/verify-it)\n[![dependencies Status](https://david-dm.org/bbc/verify-it/status.svg)](https://david-dm.org/bbc/verify-it)\n[![devDependencies Status](https://david-dm.org/bbc/verify-it/dev-status.svg)](https://david-dm.org/bbc/verify-it?type=dev)\n\nThis module provides:\n\n* Randomised property inputs for testing (delegating the actual testing to a global `it` or `test` function).\n* Global `verify.it` and `verify.test` functions (which are synonyms).\n* A global `verify.describe` function (delegating the actual testing to a global `describe` function).\n* A series of generator functions that can be used to generate properties.\n* Generators are simply functions that produce a value so custom generators are simple to create.\n\nWhat it is not:\n\n* A property-based testing framework - each test scenario is only run once with the requested randomised inputs.\n\n## Usage\n\nA global `it` or `test` function is required for `verify-it` to delegate testing to (`it` is used in preference to `test`). This could be provided by [mocha](https://www.npmjs.com/package/mocha), [jest](https://www.npmjs.com/package/jest), [jasmine](https://www.npmjs.com/package/jasmine) or a similar testing framework.\n\nA simple `mocha` example would be:\n\n```javascript\nrequire('mocha')\nconst { Gen } = require('verify-it')\n\nconst myGenerator = () =\u003e `My custom generated value: ${Math.random()}`\n\ndescribe('The verify-it library', () =\u003e {\n  verify.it('should inject randomised properties',\n    Gen.string, Gen.object, myGenerator,\n    (someString, someObject, someCustomValue) =\u003e {\n      // Write your tests here in the usual way using the supplied randomised values...\n    }\n  )\n\n  verify.it('should allow testing of asynchronous callbacks if the test framework supports it', () =\u003e {\n    Gen.string, Gen.object, myGenerator,\n    (someString, someObject, someCustomValue, done) =\u003e {\n      // Write some more tests here but call the done function when finished\n      done()\n    }\n  )\n\n  verify.describe('when verify.describe is used', Gen.object, (someObject) =\u003e {\n    verify.it('allows the same generated value to be shared across multiple tests',\n      Gen.object, (someOtherObject) =\u003e {\n        // Write your tests here using both someObject and someOtherObject\n      }\n    )\n  })\n})\n```\n\nIf your test framework has `test.only` or `it.only` and `test.skip` or `test.skip` then `verify.it.only`, `verify.test.only`, `verify.it.skip`, and `verify.it.skip` will also be available. Similarly, if `describe.only` or `describe.skip` exist, `verify.describe.only` and `verify.describe.skip` will be available.\n\n## Generators\n\nGenerators are simply functions that produce a value. Several built-in generators are supplied:\n\n```javascript\nconst { Gen } = require('verify-it')\n```\n\n| Function                          | Produces  | Notes |\n|-----------------------------------|-----------|-------|\n| `Gen.word`                        | `string`  | Produces an english word picked at random from a word list. |\n| `Gen.string`                      | `string`  | Produces a random string between 1 and 100 characters in length. |\n| `Gen.stringWithLength(length)`    | `string`  | Produces a random string with a fixed length. |\n| `Gen.stringNonNumeric`            | `string`  | Produces a random string that does not contain numeric characters between 1 and 100 characters in length. |\n| `Gen.integer`                     | `number`  | Produces a random integer in the inclusive range between `Number.MIN_SAFE_INTEGER` and `Number.MAX_SAFE_INTEGER`. |\n| `Gen.integerBetween(min, max)`    | `number`  | Produces a random integer in the inclusive range between `min` and `max`. |\n| `Gen.float`                       | `number`  | Produces a random number in the inclusive range between `-1E10` and `1E10` |\n| `Gen.floatBetween(min, max)`      | `number`  | Produces a random number in the inclusive range between `min` and `max` |\n| `Gen.object`                      | `Object`  | Produces an object with random word keys and randomised string values. |\n| `Gen.objectWith(...keys)`         | `Object`  | Produces an object with the supplied keys and randomised string values. |\n| `Gen.error`                       | `Error`   | Produces an `Error` with a random message string. |\n| `Gen.boolean`                     | `boolean` | Produces a random boolean value |\n| `Gen.array(generator, length)`    | `Array`   | Produces an array with `length` elements (or between 1 and 100 elements if `length` is omitted) generated using `generator`. e.g. `Gen.array(Gen.string)` will produce an array of strings. |\n| `Gen.distinct(generator, length)` | `Array`   | Produces an array of length `length` with distinct values generated using `generator`. Equality is based on `===`. If distinct values cannot be generated after 10 generation attempts, an error will be thrown. |\n| `Gen.pick(values)`                | `any`     | Picks a random element from the supplied `values` array. |\n\n## Development\n\n* Install dependencies: `yarn install`.\n* Run all tests: `yarn test`.\n* Check dependencies for security vulnerabilities and licensing issues: `yarn check-dependencies`.\n\n## Contributing\n\nSee [these notes](./.github/CONTRIBUTING.md) for information for contributors.\n\n## License\n\n`verify-it` is available to all via the [Apache-2.0](./LICENSE) license.\n\nCopyright \u0026copy; 2017 BBC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbc%2Fverify-it","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbbc%2Fverify-it","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbc%2Fverify-it/lists"}