{"name":"jest-each","version":"24.7.0","keywords":["jest","parameterised","test","each"],"author":{"url":"mattphillips","name":"Matt Phillips"},"license":"MIT","_id":"jest-each@24.7.0","maintainers":[{"name":"mattphillips","email":"matt@mattphillips.io"},{"name":"mjesun","email":"mjesun@hotmail.com"},{"name":"rubennorte","email":"rubennorte@gmail.com"},{"name":"scotthovestadt","email":"scott.hovestadt@gmail.com"}],"homepage":"https://github.com/facebook/jest#readme","bugs":{"url":"https://github.com/facebook/jest/issues"},"dist":{"shasum":"7850862106bc9ecb875ffb8eb5e3d3fd9885208f","tarball":"http://registry-npm.ywwl.com/jest-each/download/jest-each-24.7.0.tgz","fileCount":20,"integrity":"sha512-QIva7rgK9R+23uQUnqgSRlZJ5MwJIVanoQNzRZl0zbhv9M05TDqoneVOhpQyDM5ZUJjqCLzwu0PoG6L8U7i8qA==","signatures":[{"sig":"MEUCIDFYIYRj8LnwzfacF5xixa1J8mQE7varDoorJ136kNsQAiEAmtox30PL4wgO93UgX1LTUCr8ayb4eMDhDQrWHAhMmTk=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":218349,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJcpC6+CRA9TVsSAnZWagAA6AkP/1Hi9xhsCXYBROZd7EgU\nqWtFS+3rkZDpztpw9wKc2ZTAXyxktausiONyhosrG88y/Ud4fsg/sTCYvwL4\nMhNy4QVXV4wR2QWoU1i3lMTvygfGBhu59OvNO/0xq/GdGI5caPPxs8odWzWq\njTk4qbzK4vA9jqBwpXE+NmT1huwePzdT4Aou53cJA5wp68/3BV+/zKrKusG+\n+hCjKTqCMWh4Nmh4Yxuz70PqcYcZ0F3p27lSUeOuTtIcG4NwSeWPbpJ7k0zd\nGbtLkiHvTQt+6qPRh/Lq38O8jslM+y4qD8oHs9Z/Ndf0CHLfclTzBYe9rTCE\nnOCw8xEVX964yCtCtNx81l3qyEnaqsX81d+FQ4IBfqMqvszyYEkVi/h1MGfw\nEVeHwO9hBrqP2VKxi0HZTW/n81O9FAqS9rh8A9Lj0i3hIX2jZGCvRdYYBx5u\n4zJVmDU4yvNgJMlLTuX0nCR+u3vijJ4yZHqiSC+3kl2hgVXPxd2ZvKJ4gU5t\nbGKkwrwidzhxBaI7wqlcT9AGsNI+WBcdv5qWlcCVBDcsNRnr6Kfu2Rcxtitw\n6WNKwa0mq2D3EX6u+5VdEr1LzGJ6iYmMSgvUKVQuvJiho06HPrHJskZ7crnM\nHra59Rpa2HIMEss90Z/1tqFV0XvLb5Bm/YerRfhJcgMDN1ph5q6UIU0UtJIP\nkk4M\r\n=WBmp\r\n-----END PGP SIGNATURE-----\r\n","size":25389,"noattachment":false,"key":"/jest-each/-/jest-each-24.7.0.tgz"},"main":"build/index.js","types":"build/index.d.ts","engines":{"node":">= 6"},"gitHead":"eb0413622542bc0f70c32950d9daeeab9f6802ac","_npmUser":{"name":"scotthovestadt","email":"scott.hovestadt@gmail.com"},"repository":{"url":"git+https://github.com/facebook/jest.git","type":"git","directory":"packages/jest-each"},"_npmVersion":"lerna/3.13.1/node@v11.12.0+x64 (darwin)","description":"Parameterised tests for Jest","directories":{},"_nodeVersion":"11.12.0","dependencies":{"chalk":"^2.0.1","jest-util":"^24.7.0","@jest/types":"^24.7.0","jest-get-type":"^24.3.0","pretty-format":"^24.7.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/jest-each_24.7.0_1554263742307_0.36740763928165476","host":"s3://npm-registry-packages"},"readme":"<div align=\"center\">\n  <h1>jest-each</h1>\n  Jest Parameterised Testing\n</div>\n\n<hr />\n\n[![version](https://img.shields.io/npm/v/jest-each.svg?style=flat-square)](https://www.npmjs.com/package/jest-each) [![downloads](https://img.shields.io/npm/dm/jest-each.svg?style=flat-square)](http://npm-stat.com/charts.html?package=jest-each&from=2017-03-21) [![MIT License](https://img.shields.io/npm/l/jest-each.svg?style=flat-square)](https://github.com/jestjs/jest/blob/main/LICENSE)\n\nA parameterised testing library for [Jest](https://jestjs.io/) inspired by [mocha-each](https://github.com/ryym/mocha-each).\n\njest-each allows you to provide multiple arguments to your `test`/`describe` which results in the test/suite being run once per row of parameters.\n\n## Features\n\n- `.test` to runs multiple tests with parameterised data\n  - Also under the alias: `.it`\n- `.test.only` to only run the parameterised tests\n  - Also under the aliases: `.it.only` or `.fit`\n- `.test.skip` to skip the parameterised tests\n  - Also under the aliases: `.it.skip` or `.xit` or `.xtest`\n- `.test.concurrent`\n  - Also under the alias: `.it.concurrent`\n- `.test.concurrent.only`\n  - Also under the alias: `.it.concurrent.only`\n- `.test.concurrent.skip`\n  - Also under the alias: `.it.concurrent.skip`\n- `.describe` to runs test suites with parameterised data\n- `.describe.only` to only run the parameterised suite of tests\n  - Also under the aliases: `.fdescribe`\n- `.describe.skip` to skip the parameterised suite of tests\n  - Also under the aliases: `.xdescribe`\n- Asynchronous tests with `done`\n- Unique test titles with [`printf` formatting](https://nodejs.org/api/util.html#util_util_format_format_args):\n  - `%p` - [pretty-format](https://www.npmjs.com/package/pretty-format).\n  - `%s`- String.\n  - `%d`- Number.\n  - `%i` - Integer.\n  - `%f` - Floating point value.\n  - `%j` - JSON.\n  - `%o` - Object.\n  - `%#` - Index of the test case.\n  - `%$` - Number of the test case.\n  - `%%` - single percent sign ('%'). This does not consume an argument.\n- Unique test titles by injecting properties of test case object\n- 🖖 Spock like data tables with [Tagged Template Literals](#tagged-template-literal-of-rows)\n\n---\n\n- [Demo](#demo)\n- [Installation](#installation)\n- [Importing](#importing)\n- APIs\n  - [Array of Rows](#array-of-rows)\n    - [Usage](#usage)\n  - [Tagged Template Literal of rows](#tagged-template-literal-of-rows)\n    - [Usage](#usage-1)\n\n## Demo\n\n#### Tests without jest-each\n\n![Current jest tests](assets/default-demo.gif)\n\n#### Tests can be re-written with jest-each to:\n\n**`.test`**\n\n![Current jest tests](assets/test-demo.gif)\n\n**`.test` with Tagged Template Literals**\n\n![Current jest tests](assets/tagged-template-literal.gif)\n\n**`.describe`**\n\n![Current jest tests](assets/describe-demo.gif)\n\n## Installation\n\n`npm i --save-dev jest-each`\n\n`yarn add -D jest-each`\n\n## Importing\n\njest-each is a default export so it can be imported with whatever name you like.\n\n```js\n// es6\nimport each from 'jest-each';\n```\n\n```js\n// es5\nconst each = require('jest-each').default;\n```\n\n## Array of rows\n\n### API\n\n#### `each([parameters]).test(name, testFn)`\n\n##### `each`:\n\n- parameters: `Array` of Arrays with the arguments that are passed into the `testFn` for each row\n  - _Note_ If you pass in a 1D array of primitives, internally it will be mapped to a table i.e. `[1, 2, 3] -> [[1], [2], [3]]`\n\n##### `.test`:\n\n- name: `String` the title of the `test`.\n  - Generate unique test titles by positionally injecting parameters with [`printf` formatting](https://nodejs.org/api/util.html#util_util_format_format_args):\n    - `%p` - [pretty-format](https://www.npmjs.com/package/pretty-format).\n    - `%s`- String.\n    - `%d`- Number.\n    - `%i` - Integer.\n    - `%f` - Floating point value.\n    - `%j` - JSON.\n    - `%o` - Object.\n    - `%#` - Index of the test case.\n    - `%$` - Number of the test case.\n    - `%%` - single percent sign ('%'). This does not consume an argument.\n  - Or generate unique test titles by injecting properties of test case object with `$variable`\n    - To inject nested object values use you can supply a keyPath i.e. `$variable.path.to.value` (only works for [\"own\" properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty), e.g. `$variable.constructor.name` wouldn't work)\n    - You can use `$#` to inject the index of the test case\n    - You cannot use `$variable` with the `printf` formatting except for `%%`\n- testFn: `Function` the test logic, this is the function that will receive the parameters of each row as function arguments\n\n#### `each([parameters]).describe(name, suiteFn)`\n\n##### `each`:\n\n- parameters: `Array` of Arrays with the arguments that are passed into the `suiteFn` for each row\n  - _Note_ If you pass in a 1D array of primitives, internally it will be mapped to a table i.e. `[1, 2, 3] -> [[1], [2], [3]]`\n\n##### `.describe`:\n\n- name: `String` the title of the `describe`\n  - Generate unique test titles by positionally injecting parameters with [`printf` formatting](https://nodejs.org/api/util.html#util_util_format_format_args):\n    - `%p` - [pretty-format](https://www.npmjs.com/package/pretty-format).\n    - `%s`- String.\n    - `%d`- Number.\n    - `%i` - Integer.\n    - `%f` - Floating point value.\n    - `%j` - JSON.\n    - `%o` - Object.\n    - `%#` - Index of the test case.\n    - `%$` - Number of the test case.\n    - `%%` - single percent sign ('%'). This does not consume an argument.\n  - Or generate unique test titles by injecting properties of test case object with `$variable`\n    - To inject nested object values use you can supply a keyPath i.e. `$variable.path.to.value` (only works for [\"own\" properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty), e.g. `$variable.constructor.name` wouldn't work)\n    - You can use `$#` to inject the index of the test case\n    - You cannot use `$variable` with the `printf` formatting except for `%%`\n- suiteFn: `Function` the suite of `test`/`it`s to be ran, this is the function that will receive the parameters in each row as function arguments\n\n### Usage\n\n#### `.test(name, fn)`\n\nAlias: `.it(name, fn)`\n\n```js\neach([\n  [1, 1, 2],\n  [1, 2, 3],\n  [2, 1, 3],\n]).test('returns the result of adding %d to %d', (a, b, expected) => {\n  expect(a + b).toBe(expected);\n});\n```\n\n```js\neach([\n  {a: 1, b: 1, expected: 2},\n  {a: 1, b: 2, expected: 3},\n  {a: 2, b: 1, expected: 3},\n]).test('returns the result of adding $a to $b', ({a, b, expected}) => {\n  expect(a + b).toBe(expected);\n});\n```\n\n#### `.test.only(name, fn)`\n\nAliases: `.it.only(name, fn)` or `.fit(name, fn)`\n\n```js\neach([\n  [1, 1, 2],\n  [1, 2, 3],\n  [2, 1, 3],\n]).test.only('returns the result of adding %d to %d', (a, b, expected) => {\n  expect(a + b).toBe(expected);\n});\n```\n\n#### `.test.skip(name, fn)`\n\nAliases: `.it.skip(name, fn)` or `.xit(name, fn)` or `.xtest(name, fn)`\n\n```js\neach([\n  [1, 1, 2],\n  [1, 2, 3],\n  [2, 1, 3],\n]).test.skip('returns the result of adding %d to %d', (a, b, expected) => {\n  expect(a + b).toBe(expected);\n});\n```\n\n#### `.test.concurrent(name, fn)`\n\nAliases: `.it.concurrent(name, fn)`\n\n```js\neach([\n  [1, 1, 2],\n  [1, 2, 3],\n  [2, 1, 3],\n]).test.concurrent(\n  'returns the result of adding %d to %d',\n  (a, b, expected) => {\n    expect(a + b).toBe(expected);\n  },\n);\n```\n\n#### `.test.concurrent.only(name, fn)`\n\nAliases: `.it.concurrent.only(name, fn)`\n\n```js\neach([\n  [1, 1, 2],\n  [1, 2, 3],\n  [2, 1, 3],\n]).test.concurrent.only(\n  'returns the result of adding %d to %d',\n  (a, b, expected) => {\n    expect(a + b).toBe(expected);\n  },\n);\n```\n\n#### `.test.concurrent.skip(name, fn)`\n\nAliases: `.it.concurrent.skip(name, fn)`\n\n```js\neach([\n  [1, 1, 2],\n  [1, 2, 3],\n  [2, 1, 3],\n]).test.concurrent.skip(\n  'returns the result of adding %d to %d',\n  (a, b, expected) => {\n    expect(a + b).toBe(expected);\n  },\n);\n```\n\n#### Asynchronous `.test(name, fn(done))`\n\nAlias: `.it(name, fn(done))`\n\n```js\neach([['hello'], ['mr'], ['spy']]).test(\n  'gives 007 secret message: %s',\n  (str, done) => {\n    const asynchronousSpy = message => {\n      expect(message).toBe(str);\n      done();\n    };\n    callSomeAsynchronousFunction(asynchronousSpy)(str);\n  },\n);\n```\n\n#### `.describe(name, fn)`\n\n```js\neach([\n  [1, 1, 2],\n  [1, 2, 3],\n  [2, 1, 3],\n]).describe('.add(%d, %d)', (a, b, expected) => {\n  test(`returns ${expected}`, () => {\n    expect(a + b).toBe(expected);\n  });\n\n  test('does not mutate first arg', () => {\n    a + b;\n    expect(a).toBe(a);\n  });\n\n  test('does not mutate second arg', () => {\n    a + b;\n    expect(b).toBe(b);\n  });\n});\n```\n\n```js\neach([\n  {a: 1, b: 1, expected: 2},\n  {a: 1, b: 2, expected: 3},\n  {a: 2, b: 1, expected: 3},\n]).describe('.add($a, $b)', ({a, b, expected}) => {\n  test(`returns ${expected}`, () => {\n    expect(a + b).toBe(expected);\n  });\n\n  test('does not mutate first arg', () => {\n    a + b;\n    expect(a).toBe(a);\n  });\n\n  test('does not mutate second arg', () => {\n    a + b;\n    expect(b).toBe(b);\n  });\n});\n```\n\n#### `.describe.only(name, fn)`\n\nAliases: `.fdescribe(name, fn)`\n\n```js\neach([\n  [1, 1, 2],\n  [1, 2, 3],\n  [2, 1, 3],\n]).describe.only('.add(%d, %d)', (a, b, expected) => {\n  test(`returns ${expected}`, () => {\n    expect(a + b).toBe(expected);\n  });\n});\n```\n\n#### `.describe.skip(name, fn)`\n\nAliases: `.xdescribe(name, fn)`\n\n```js\neach([\n  [1, 1, 2],\n  [1, 2, 3],\n  [2, 1, 3],\n]).describe.skip('.add(%d, %d)', (a, b, expected) => {\n  test(`returns ${expected}`, () => {\n    expect(a + b).toBe(expected);\n  });\n});\n```\n\n---\n\n## Tagged Template Literal of rows\n\n### API\n\n#### `each[tagged template].test(name, suiteFn)`\n\n```js\neach`\n  a    | b    | expected\n  ${1} | ${1} | ${2}\n  ${1} | ${2} | ${3}\n  ${2} | ${1} | ${3}\n`.test('returns $expected when adding $a to $b', ({a, b, expected}) => {\n  expect(a + b).toBe(expected);\n});\n```\n\n##### `each` takes a tagged template string with:\n\n- First row of variable name column headings separated with `|`\n- One or more subsequent rows of data supplied as template literal expressions using `${value}` syntax.\n\n##### `.test`:\n\n- name: `String` the title of the `test`, use `$variable` in the name string to inject test values into the test title from the tagged template expressions\n  - To inject nested object values use you can supply a keyPath i.e. `$variable.path.to.value` (only works for [\"own\" properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty), e.g. `$variable.constructor.name` wouldn't work)\n  - You can use `$#` to inject the index of the table row.\n- testFn: `Function` the test logic, this is the function that will receive the parameters of each row as function arguments\n\n#### `each[tagged template].describe(name, suiteFn)`\n\n```js\neach`\n  a    | b    | expected\n  ${1} | ${1} | ${2}\n  ${1} | ${2} | ${3}\n  ${2} | ${1} | ${3}\n`.describe('$a + $b', ({a, b, expected}) => {\n  test(`returns ${expected}`, () => {\n    expect(a + b).toBe(expected);\n  });\n\n  test('does not mutate first arg', () => {\n    a + b;\n    expect(a).toBe(a);\n  });\n\n  test('does not mutate second arg', () => {\n    a + b;\n    expect(b).toBe(b);\n  });\n});\n```\n\n##### `each` takes a tagged template string with:\n\n- First row of variable name column headings separated with `|`\n- One or more subsequent rows of data supplied as template literal expressions using `${value}` syntax.\n\n##### `.describe`:\n\n- name: `String` the title of the `test`, use `$variable` in the name string to inject test values into the test title from the tagged template expressions\n  - To inject nested object values use you can supply a keyPath i.e. `$variable.path.to.value` (only works for [\"own\" properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty), e.g. `$variable.constructor.name` wouldn't work)\n- suiteFn: `Function` the suite of `test`/`it`s to be ran, this is the function that will receive the parameters in each row as function arguments\n\n### Usage\n\n#### `.test(name, fn)`\n\nAlias: `.it(name, fn)`\n\n```js\neach`\n  a    | b    | expected\n  ${1} | ${1} | ${2}\n  ${1} | ${2} | ${3}\n  ${2} | ${1} | ${3}\n`.test('returns $expected when adding $a to $b', ({a, b, expected}) => {\n  expect(a + b).toBe(expected);\n});\n```\n\n#### `.test.only(name, fn)`\n\nAliases: `.it.only(name, fn)` or `.fit(name, fn)`\n\n```js\neach`\n  a    | b    | expected\n  ${1} | ${1} | ${2}\n  ${1} | ${2} | ${3}\n  ${2} | ${1} | ${3}\n`.test.only('returns $expected when adding $a to $b', ({a, b, expected}) => {\n  expect(a + b).toBe(expected);\n});\n```\n\n#### `.test.skip(name, fn)`\n\nAliases: `.it.skip(name, fn)` or `.xit(name, fn)` or `.xtest(name, fn)`\n\n```js\neach`\n  a    | b    | expected\n  ${1} | ${1} | ${2}\n  ${1} | ${2} | ${3}\n  ${2} | ${1} | ${3}\n`.test.skip('returns $expected when adding $a to $b', ({a, b, expected}) => {\n  expect(a + b).toBe(expected);\n});\n```\n\n#### Asynchronous `.test(name, fn(done))`\n\nAlias: `.it(name, fn(done))`\n\n```js\neach`\n  str\n  ${'hello'}\n  ${'mr'}\n  ${'spy'}\n`.test('gives 007 secret message: $str', ({str}, done) => {\n  const asynchronousSpy = message => {\n    expect(message).toBe(str);\n    done();\n  };\n  callSomeAsynchronousFunction(asynchronousSpy)(str);\n});\n```\n\n#### `.describe(name, fn)`\n\n```js\neach`\n  a    | b    | expected\n  ${1} | ${1} | ${2}\n  ${1} | ${2} | ${3}\n  ${2} | ${1} | ${3}\n`.describe('$a + $b', ({a, b, expected}) => {\n  test(`returns ${expected}`, () => {\n    expect(a + b).toBe(expected);\n  });\n\n  test('does not mutate first arg', () => {\n    a + b;\n    expect(a).toBe(a);\n  });\n\n  test('does not mutate second arg', () => {\n    a + b;\n    expect(b).toBe(b);\n  });\n});\n```\n\n#### `.describe.only(name, fn)`\n\nAliases: `.fdescribe(name, fn)`\n\n```js\neach`\n  a    | b    | expected\n  ${1} | ${1} | ${2}\n  ${1} | ${2} | ${3}\n  ${2} | ${1} | ${3}\n`.describe.only('$a + $b', ({a, b, expected}) => {\n  test(`returns ${expected}`, () => {\n    expect(a + b).toBe(expected);\n  });\n});\n```\n\n#### `.describe.skip(name, fn)`\n\nAliases: `.xdescribe(name, fn)`\n\n```js\neach`\n  a    | b    | expected\n  ${1} | ${1} | ${2}\n  ${1} | ${2} | ${3}\n  ${2} | ${1} | ${3}\n`.describe.skip('$a + $b', ({a, b, expected}) => {\n  test(`returns ${expected}`, () => {\n    expect(a + b).toBe(expected);\n  });\n});\n```\n\n## License\n\nMIT\n","publish_time":1554263742450,"_cnpm_publish_time":1554263742450,"dist-tags":{"latest":"30.5.2","next":"30.0.0-rc.1"}}