{"_id":"jest-in-case","_rev":"9-07ec316b5b7a5030dbd583e1e8a7302e","name":"jest-in-case","description":"Jest utility for creating variations of the same test","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"jest-in-case","version":"1.0.0","description":"Jest utility for creating variantions of the same test","main":"index.js","repository":{"type":"git","url":"git+https://github.com/thinkmill/jest-in-case.git"},"author":{"name":"James Kyle","email":"me@thejameskyle.com"},"license":"MIT","files":["index.js"],"keywords":["jest","test","testing"],"scripts":{"test":"jest"},"devDependencies":{"flow-bin":"^0.53.1","jest":"^20.0.4"},"gitHead":"c45e080447fee4fdaac1db982bbff356f8afbc8b","bugs":{"url":"https://github.com/thinkmill/jest-in-case/issues"},"homepage":"https://github.com/thinkmill/jest-in-case#readme","_id":"jest-in-case@1.0.0","_shasum":"e66e63b2e714a423d5cf6cae3bfda203cbf72145","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"thejameskyle","email":"me@thejameskyle.com"},"dist":{"shasum":"e66e63b2e714a423d5cf6cae3bfda203cbf72145","tarball":"https://registry.npmjs.org/jest-in-case/-/jest-in-case-1.0.0.tgz","integrity":"sha512-2H5fR0bmiQQ+BVd2snBYGCcU5V4uWvAUEF7PLB6V5FQY16qxwL92zAEqyp9WrsT5VB7k3OqXO5zaGP4UeKbovg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDBz3pddF4WZA2YlX0xroq6hKs1GllbUglFzqGQ/eAD9wIgdW8yQCzxPnF0nKz39kBiH8oGy+zqeKBYcmuRZ2Lnd78="}]},"maintainers":[{"name":"thejameskyle","email":"me@thejameskyle.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jest-in-case-1.0.0.tgz_1504174762005_0.65824731788598"},"directories":{}},"1.0.1":{"name":"jest-in-case","version":"1.0.1","description":"Jest utility for creating variantions of the same test","main":"index.js","repository":{"type":"git","url":"git+https://github.com/thinkmill/jest-in-case.git"},"author":{"name":"James Kyle","email":"me@thejameskyle.com"},"license":"MIT","files":["index.js"],"keywords":["jest","test","testing"],"scripts":{"test":"jest"},"devDependencies":{"flow-bin":"^0.53.1","jest":"^20.0.4"},"gitHead":"dcb62a15c2dbd03df5c869b634a6d4f08efb321a","bugs":{"url":"https://github.com/thinkmill/jest-in-case/issues"},"homepage":"https://github.com/thinkmill/jest-in-case#readme","_id":"jest-in-case@1.0.1","_shasum":"57b5e1c105c3849dfb3e82ea8f7073a3c1dd35e6","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"thejameskyle","email":"me@thejameskyle.com"},"dist":{"shasum":"57b5e1c105c3849dfb3e82ea8f7073a3c1dd35e6","tarball":"https://registry.npmjs.org/jest-in-case/-/jest-in-case-1.0.1.tgz","integrity":"sha512-o6CY+mwnLgSdhkHK+VEm/ddIaAqTmYqXVQHptJj/rtM2OSdqGgfujhZfdfB+NqFLrvLhTQh+f1jAR7UNJUj/NA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCBPLw2BBwm0VLtjErD83bemCLHXGK6iG2EVi7J1EvkEgIhAMY223/NP6T5XcPWS8L00DbFTRp8jYY1SXMMzrxMy7nn"}]},"maintainers":[{"name":"thejameskyle","email":"me@thejameskyle.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jest-in-case-1.0.1.tgz_1504175054571_0.41476755775511265"},"directories":{}},"1.0.2":{"name":"jest-in-case","version":"1.0.2","description":"Jest utility for creating variations of the same test","main":"index.js","repository":{"type":"git","url":"git+https://github.com/thinkmill/jest-in-case.git"},"author":{"name":"James Kyle","email":"me@thejameskyle.com"},"license":"MIT","engines":{"node":">=4"},"files":["index.js"],"keywords":["jest","test","testing"],"scripts":{"test":"jest"},"devDependencies":{"flow-bin":"^0.53.1","jest":"^20.0.4"},"gitHead":"62b543b219dd6caf02df2cef0d4b53a76cd00edc","bugs":{"url":"https://github.com/thinkmill/jest-in-case/issues"},"homepage":"https://github.com/thinkmill/jest-in-case#readme","_id":"jest-in-case@1.0.2","_shasum":"56744b5af33222bd0abab70cf919f1d170ab75cc","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.9.1","_npmUser":{"name":"thejameskyle","email":"me@thejameskyle.com"},"dist":{"shasum":"56744b5af33222bd0abab70cf919f1d170ab75cc","tarball":"https://registry.npmjs.org/jest-in-case/-/jest-in-case-1.0.2.tgz","integrity":"sha512-2DE6Gdwnh5jkCYTePWoQinF+zne3lCADibXoYJEt8PS84JaRug0CyAOrEgzMxbzln3YcSY2PBeru7ct4tbflYA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIF1Y5I3sdu+Y1kWmEgzH1VH6bzIfDVC19WqdwLG/SseQAiBm1VTPGR4867NzyKj8gKvXqMKd07inBQnOZcUPSb3mMQ=="}]},"maintainers":[{"name":"thejameskyle","email":"me@thejameskyle.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jest-in-case-1.0.2.tgz_1504857817604_0.8177926719654351"},"directories":{}}},"readme":"# jest-in-case\n\n> [Jest](https://facebook.github.io/jest/) utility for creating variations of\n> the same test\n\n## Example\n\n```js\nimport { add, subtract } from './math';\nimport cases from 'jest-in-case';\n\ncases('add(augend, addend)', opts => {\n  expect(add(opts.augend, opts.addend)).toBe(opts.total);\n}, [\n  { name: '1 + 1 = 2', augend: 1, addend: 1, total: 2 },\n  { name: '2 + 1 = 3', augend: 2, addend: 1, total: 3 },\n  { name: '3 + 1 = 4', augend: 3, addend: 1, total: 4 },\n]);\n```\n\n## Installation\n\n```sh\nyarn add --dev jest-in-case\n```\n\n## Usage\n\nIn your [Jest](https://facebook.github.io/jest/) tests, import `cases` from\n`jest-in-case`.\n\n```js\nimport cases from 'jest-in-case';\n// or\nconst cases = require('jest-in-case');\n```\n\nThen you can call `cases` with a `title`, a `tester`, and some `testCases`.\n\n```js\ncases(title, tester, testCases);\n```\n\n`cases` can either be an array of objects with a `name` property:\n\n```js\ncases('add(augend, addend)', opts => {\n  expect(add(opts.augend, opts.addend)).toBe(opts.total);\n}, [\n  { name: '1 + 1 = 2', augend: 1, addend: 1, total: 2 },\n  { name: '2 + 1 = 3', augend: 2, addend: 1, total: 3 },\n  { name: '3 + 1 = 4', augend: 3, addend: 1, total: 4 },\n]);\n```\n\nOr an object of objects with the names as the keys:\n\n```js\ncases('subtract(minuend, subtrahend)', opts => {\n  expect(subtract(opts.minuend, opts.subtrahend)).toBe(opts.difference);\n}, {\n  '1 - 1 = 0': { minuend: 1, subtrahend: 1, difference: 0 },\n  '2 - 1 = 1': { minuend: 2, subtrahend: 1, difference: 1 },\n  '3 - 1 = 2': { minuend: 3, subtrahend: 1, difference: 2 },\n});\n```\n\nInsider of a test case you can put whatever properties you want, except for\n`name`, `only`, or `skip`:\n\n```js\ncases('title', fn, [\n  { name: 'reserved 1', only: true, skip: true, whatever: 'you', want: 'here' },\n  { name: 'reserved 2', only: true, skip: true, whatever: 'you', want: 'here' },\n  { name: 'reserved 3', only: true, skip: true, whatever: 'you', want: 'here' },\n]);\n```\n\n- `name` is passed to `test(name, fn)` to become the name of your test\n- When `only` is set to `true` it will use Jest's `test.only` function\n- When `skip` is set to `true` it will use Jest's `test.skip` function\n\nThe `tester` function is called on each test case with your options:\n\n```js\ncases('title', opts => {\n  console.log('passed: ', opts);\n}, {\n  'test 1': { foo: 1 },\n  'test 2': { bar: 2 },\n  'test 3': { baz: 3 },\n});\n\n// passed: { foo: 1 }\n// passed: { bar: 2 }\n// passed: { baz: 3 }\n```\n\nYour tester function works just like functions passed to Jest's `test` function\ndo (Just with a prepended argument):\n\n```js\ncases('async functions', async opts => {\n  let result = await somethingAsync(opts.input);\n  expect(result).toEqual(opts.result);\n}, {\n  'test 1': { ... },\n  'test 2': { ... },\n});\n\ncases('done callback', (opts, done) => {\n  somethingAsync(opts.input, result => {\n    expect(result).toEqual(result);\n    done();\n  });\n}, {\n  'test 1': { ... },\n  'test 2': { ... },\n});\n```\n","maintainers":[{"name":"thejameskyle","email":"me@thejameskyle.com"}],"time":{"modified":"2022-06-19T04:11:52.781Z","created":"2017-08-31T10:19:22.404Z","1.0.0":"2017-08-31T10:19:22.404Z","1.0.1":"2017-08-31T10:24:14.640Z","1.0.2":"2017-09-08T08:03:37.718Z"},"homepage":"https://github.com/thinkmill/jest-in-case#readme","keywords":["jest","test","testing"],"repository":{"type":"git","url":"git+https://github.com/thinkmill/jest-in-case.git"},"author":{"name":"James Kyle","email":"me@thejameskyle.com"},"bugs":{"url":"https://github.com/thinkmill/jest-in-case/issues"},"license":"MIT","readmeFilename":"README.md","users":{"kontrax":true}}