jest-each
Advanced tools
Comparing version 0.5.0 to 23.0.1
{ | ||
"name": "jest-each", | ||
"version": "0.5.0", | ||
"version": "23.0.1", | ||
"description": "Parameterised tests for Jest", | ||
"main": "dist/index.js", | ||
"files": [ | ||
"dist", | ||
"README.md" | ||
], | ||
"scripts": { | ||
"build": "babel src -d dist --ignore *.test.js", | ||
"prepublish": "npm run build", | ||
"test": "jest --testPathPattern=src", | ||
"test:coveralls": "npm run test:coverage && cat ./coverage/lcov.info | coveralls", | ||
"test:coverage": "jest --coverage" | ||
}, | ||
"main": "build/index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/mattphillips/jest-each.git" | ||
"url": "https://github.com/facebook/jest.git" | ||
}, | ||
@@ -29,32 +18,6 @@ "keywords": [ | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/mattphillips/jest-each/issues" | ||
}, | ||
"homepage": "https://github.com/mattphillips/jest-each#readme", | ||
"devDependencies": { | ||
"babel-cli": "^6.24.0", | ||
"babel-core": "^6.24.0", | ||
"babel-jest": "^19.0.0", | ||
"babel-plugin-add-module-exports": "^0.2.1", | ||
"babel-plugin-gwt": "^1.0.0", | ||
"babel-plugin-transform-es2015-modules-umd": "^6.24.0", | ||
"babel-preset-es2015": "^6.24.0", | ||
"babel-preset-stage-0": "^6.22.0", | ||
"coveralls": "^2.12.0", | ||
"jest": "^19.0.2" | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"stage-0", | ||
"es2015" | ||
], | ||
"plugins": [ | ||
"add-module-exports", | ||
"transform-es2015-modules-umd", | ||
"gwt" | ||
] | ||
}, | ||
"dependencies": { | ||
"sprintf-js": "^1.0.3" | ||
"chalk": "^2.0.1", | ||
"pretty-format": "^23.0.1" | ||
} | ||
} |
248
README.md
@@ -8,9 +8,3 @@ <div align="center"> | ||
[![Build Status](https://img.shields.io/travis/mattphillips/jest-each.svg?style=flat-square)](https://travis-ci.org/mattphillips/jest-each) | ||
[![Code Coverage](https://img.shields.io/coveralls/mattphillips/jest-each.svg?style=flat-square)](https://coveralls.io/github/mattphillips/jest-each?branch=master) | ||
[![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/mattphillips/jest-each/blob/master/LICENSE) | ||
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) | ||
[![Examples](https://img.shields.io/badge/%F0%9F%92%A1-examples-ff615b.svg?style=flat-square)](https://github.com/mattphillips/jest-each/tree/master/examples) | ||
[![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/facebook/jest/blob/master/LICENSE) | ||
@@ -22,27 +16,28 @@ A parameterised testing library for [Jest](https://facebook.github.io/jest/) inspired by [mocha-each](https://github.com/ryym/mocha-each). | ||
## Features | ||
- `.test` to runs multiple tests with parameterised data | ||
* Also under the alias: `.it` | ||
- `.test.only` to only run the parameterised tests | ||
* Also under the aliases: `.it.only` or `.fit` | ||
- `.test.skip` to skip the parameterised tests | ||
* Also under the aliases: `.it.skip` or `.xit` or `.xtest` | ||
- `.describe` to runs test suites with parameterised data | ||
- `.describe.only` to only run the parameterised suite of tests | ||
* Also under the aliases: `.fdescribe` | ||
- `.describe.skip` to skip the parameterised suite of tests | ||
* Also under the aliases: `.xdescribe` | ||
- Asynchronous tests with `done` | ||
- Unique test titles with: [sprintf](https://github.com/alexei/sprintf.js) | ||
- 🖖 Spock like data tables with [Tagged Template Literals](#tagged-template-literal-of-rows) | ||
* `.test` to runs multiple tests with parameterised data | ||
* Also under the alias: `.it` | ||
* `.test.only` to only run the parameterised tests | ||
* Also under the aliases: `.it.only` or `.fit` | ||
* `.test.skip` to skip the parameterised tests | ||
* Also under the aliases: `.it.skip` or `.xit` or `.xtest` | ||
* `.describe` to runs test suites with parameterised data | ||
* `.describe.only` to only run the parameterised suite of tests | ||
* Also under the aliases: `.fdescribe` | ||
* `.describe.skip` to skip the parameterised suite of tests | ||
* Also under the aliases: `.xdescribe` | ||
* Asynchronous tests with `done` | ||
* Unique test titles with: [sprintf](https://github.com/alexei/sprintf.js) | ||
* 🖖 Spock like data tables with [Tagged Template Literals](#tagged-template-literal-of-rows) | ||
--- | ||
- [Demo](#demo) | ||
- [Installation](#installation) | ||
- [Importing](#importing) | ||
- APIs | ||
* [Array of Rows](#array-of-rows) | ||
- [Usage](#usage) | ||
* [Tagged Template Literal of rows](#tagged-template-literal-of-rows) | ||
- [Usage](#usage-1) | ||
* [Demo](#demo) | ||
* [Installation](#installation) | ||
* [Importing](#importing) | ||
* APIs | ||
* [Array of Rows](#array-of-rows) | ||
* [Usage](#usage) | ||
* [Tagged Template Literal of rows](#tagged-template-literal-of-rows) | ||
* [Usage](#usage-1) | ||
@@ -94,73 +89,77 @@ ## Demo | ||
##### `each`: | ||
- parameters: `Array` of Arrays with the arguments that are passed into the `testFn` for each row | ||
* parameters: `Array` of Arrays with the arguments that are passed into the `testFn` for each row | ||
##### `.test`: | ||
- name: `String` the title of the `test`, use `%s` in the name string to positionally inject parameter values into the test title | ||
- testFn: `Function` the test logic, this is the function that will receive the parameters of each row as function arguments | ||
* name: `String` the title of the `test`, use `%s` in the name string to positionally inject parameter values into the test title | ||
* testFn: `Function` the test logic, this is the function that will receive the parameters of each row as function arguments | ||
#### `each([parameters]).describe(name, suiteFn)` | ||
##### `each`: | ||
- parameters: `Array` of Arrays with the arguments that are passed into the `suiteFn` for each row | ||
* parameters: `Array` of Arrays with the arguments that are passed into the `suiteFn` for each row | ||
##### `.describe`: | ||
- name: `String` the title of the `describe`, use `%s` in the name string to positionally inject parameter values into the suite title | ||
- 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 | ||
* name: `String` the title of the `describe`, use `%s` in the name string to positionally inject parameter values into the suite title | ||
* 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 | ||
### Usage | ||
#### `.test(name, fn)` | ||
Alias: `.it(name, fn)` | ||
```js | ||
each([ | ||
[1, 1, 2], | ||
[1, 2, 3], | ||
[2, 1, 3], | ||
]).test('returns the result of adding %s to %s', (a, b, expected) => { | ||
expect(a + b).toBe(expected); | ||
}); | ||
each([[1, 1, 2], [1, 2, 3], [2, 1, 3]]).test( | ||
'returns the result of adding %s to %s', | ||
(a, b, expected) => { | ||
expect(a + b).toBe(expected); | ||
}, | ||
); | ||
``` | ||
#### `.test.only(name, fn)` | ||
Aliases: `.it.only(name, fn)` or `.fit(name, fn)` | ||
```js | ||
each([ | ||
[1, 1, 2], | ||
[1, 2, 3], | ||
[2, 1, 3], | ||
]).test.only('returns the result of adding %s to %s', (a, b, expected) => { | ||
expect(a + b).toBe(expected); | ||
}); | ||
each([[1, 1, 2], [1, 2, 3], [2, 1, 3]]).test.only( | ||
'returns the result of adding %s to %s', | ||
(a, b, expected) => { | ||
expect(a + b).toBe(expected); | ||
}, | ||
); | ||
``` | ||
#### `.test.skip(name, fn)` | ||
Aliases: `.it.skip(name, fn)` or `.xit(name, fn)` or `.xtest(name, fn)` | ||
```js | ||
each([ | ||
[1, 1, 2] | ||
[1, 2, 3], | ||
[2, 1, 3], | ||
]).test.skip('returns the result of adding %s to %s', (a, b, expected) => { | ||
expect(a + b).toBe(expected); | ||
}); | ||
each([[1, 1, 2][(1, 2, 3)], [2, 1, 3]]).test.skip( | ||
'returns the result of adding %s to %s', | ||
(a, b, expected) => { | ||
expect(a + b).toBe(expected); | ||
}, | ||
); | ||
``` | ||
#### Asynchronous `.test(name, fn(done))` | ||
Alias: `.it(name, fn(done))` | ||
```js | ||
each([ | ||
['hello'], | ||
['mr'], | ||
['spy'], | ||
]).test('gives 007 secret message ', (str, done) => { | ||
const asynchronousSpy = (message) => { | ||
expect(message).toBe(str); | ||
done(); | ||
}; | ||
callSomeAsynchronousFunction(asynchronousSpy)(str); | ||
}); | ||
each([['hello'], ['mr'], ['spy']]).test( | ||
'gives 007 secret message ', | ||
(str, done) => { | ||
const asynchronousSpy = message => { | ||
expect(message).toBe(str); | ||
done(); | ||
}; | ||
callSomeAsynchronousFunction(asynchronousSpy)(str); | ||
}, | ||
); | ||
``` | ||
@@ -171,51 +170,50 @@ | ||
```js | ||
each([ | ||
[1, 1, 2], | ||
[1, 2, 3], | ||
[2, 1, 3], | ||
]).describe('.add(%s, %s)', (a, b, expected) => { | ||
test(`returns ${expected}`, () => { | ||
expect(a + b).toBe(expected); | ||
}); | ||
each([[1, 1, 2], [1, 2, 3], [2, 1, 3]]).describe( | ||
'.add(%s, %s)', | ||
(a, b, expected) => { | ||
test(`returns ${expected}`, () => { | ||
expect(a + b).toBe(expected); | ||
}); | ||
test('does not mutate first arg', () => { | ||
a + b; | ||
expect(a).toBe(a); | ||
}); | ||
test('does not mutate first arg', () => { | ||
a + b; | ||
expect(a).toBe(a); | ||
}); | ||
test('does not mutate second arg', () => { | ||
a + b; | ||
expect(b).toBe(b); | ||
}); | ||
}); | ||
test('does not mutate second arg', () => { | ||
a + b; | ||
expect(b).toBe(b); | ||
}); | ||
}, | ||
); | ||
``` | ||
#### `.describe.only(name, fn)` | ||
Aliases: `.fdescribe(name, fn)` | ||
```js | ||
each([ | ||
[1, 1, 2], | ||
[1, 2, 3], | ||
[2, 1, 3], | ||
]).describe.only('.add(%s, %s)', (a, b, expected) => { | ||
test(`returns ${expected}`, () => { | ||
expect(a + b).toBe(expected); | ||
}); | ||
}); | ||
each([[1, 1, 2], [1, 2, 3], [2, 1, 3]]).describe.only( | ||
'.add(%s, %s)', | ||
(a, b, expected) => { | ||
test(`returns ${expected}`, () => { | ||
expect(a + b).toBe(expected); | ||
}); | ||
}, | ||
); | ||
``` | ||
#### `.describe.skip(name, fn)` | ||
Aliases: `.xdescribe(name, fn)` | ||
```js | ||
each([ | ||
[1, 1, 2], | ||
[1, 2, 3], | ||
[2, 1, 3], | ||
]).describe.skip('.add(%s, %s)', (a, b, expected) => { | ||
test(`returns ${expected}`, () => { | ||
expect(a + b).toBe(expected); | ||
}); | ||
}); | ||
each([[1, 1, 2], [1, 2, 3], [2, 1, 3]]).describe.skip( | ||
'.add(%s, %s)', | ||
(a, b, expected) => { | ||
test(`returns ${expected}`, () => { | ||
expect(a + b).toBe(expected); | ||
}); | ||
}, | ||
); | ||
``` | ||
@@ -237,3 +235,3 @@ | ||
${2} | ${1} | ${3} | ||
`.test('returns $expected when adding $a to $b', ({ a, b, expected }) => { | ||
`.test('returns $expected when adding $a to $b', ({a, b, expected}) => { | ||
expect(a + b).toBe(expected); | ||
@@ -244,9 +242,11 @@ }); | ||
##### `each` takes a tagged template string with: | ||
- First row of variable name column headings seperated with `|` | ||
- One or more subsequent rows of data supplied as template literal expressions using `${value}` syntax. | ||
* First row of variable name column headings seperated with `|` | ||
* One or more subsequent rows of data supplied as template literal expressions using `${value}` syntax. | ||
##### `.test`: | ||
- 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 | ||
- testFn: `Function` the test logic, this is the function that will receive the parameters of each row as function arguments | ||
* 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 | ||
* testFn: `Function` the test logic, this is the function that will receive the parameters of each row as function arguments | ||
#### `each[tagged template].describe(name, suiteFn)` | ||
@@ -260,3 +260,3 @@ | ||
${2} | ${1} | ${3} | ||
`.describe('$a + $b', ({ a, b, expected }) => { | ||
`.describe('$a + $b', ({a, b, expected}) => { | ||
test(`returns ${expected}`, () => { | ||
@@ -279,12 +279,15 @@ expect(a + b).toBe(expected); | ||
##### `each` takes a tagged template string with: | ||
- First row of variable name column headings seperated with `|` | ||
- One or more subsequent rows of data supplied as template literal expressions using `${value}` syntax. | ||
* First row of variable name column headings seperated with `|` | ||
* One or more subsequent rows of data supplied as template literal expressions using `${value}` syntax. | ||
##### `.describe`: | ||
- 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 | ||
- 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 | ||
* 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 | ||
* 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 | ||
### Usage | ||
#### `.test(name, fn)` | ||
Alias: `.it(name, fn)` | ||
@@ -298,3 +301,3 @@ | ||
${2} | ${1} | ${3} | ||
`.test('returns $expected when adding $a to $b', ({ a, b, expected }) => { | ||
`.test('returns $expected when adding $a to $b', ({a, b, expected}) => { | ||
expect(a + b).toBe(expected); | ||
@@ -305,2 +308,3 @@ }); | ||
#### `.test.only(name, fn)` | ||
Aliases: `.it.only(name, fn)` or `.fit(name, fn)` | ||
@@ -314,3 +318,3 @@ | ||
${2} | ${1} | ${3} | ||
`.test.only('returns $expected when adding $a to $b', ({ a, b, expected }) => { | ||
`.test.only('returns $expected when adding $a to $b', ({a, b, expected}) => { | ||
expect(a + b).toBe(expected); | ||
@@ -321,2 +325,3 @@ }); | ||
#### `.test.skip(name, fn)` | ||
Aliases: `.it.skip(name, fn)` or `.xit(name, fn)` or `.xtest(name, fn)` | ||
@@ -330,3 +335,3 @@ | ||
${2} | ${1} | ${3} | ||
`.test.skip('returns $expected when adding $a to $b', ({ a, b, expected }) => { | ||
`.test.skip('returns $expected when adding $a to $b', ({a, b, expected}) => { | ||
expect(a + b).toBe(expected); | ||
@@ -337,2 +342,3 @@ }); | ||
#### Asynchronous `.test(name, fn(done))` | ||
Alias: `.it(name, fn(done))` | ||
@@ -346,4 +352,4 @@ | ||
${'spy'} | ||
`.test('gives 007 secret message: $str', ({ str }, done) => { | ||
const asynchronousSpy = (message) => { | ||
`.test('gives 007 secret message: $str', ({str}, done) => { | ||
const asynchronousSpy = message => { | ||
expect(message).toBe(str); | ||
@@ -364,3 +370,3 @@ done(); | ||
${2} | ${1} | ${3} | ||
`.describe('$a + $b', ({ a, b, expected }) => { | ||
`.describe('$a + $b', ({a, b, expected}) => { | ||
test(`returns ${expected}`, () => { | ||
@@ -383,2 +389,3 @@ expect(a + b).toBe(expected); | ||
#### `.describe.only(name, fn)` | ||
Aliases: `.fdescribe(name, fn)` | ||
@@ -392,3 +399,3 @@ | ||
${2} | ${1} | ${3} | ||
`.describe.only('$a + $b', ({ a, b, expected }) => { | ||
`.describe.only('$a + $b', ({a, b, expected}) => { | ||
test(`returns ${expected}`, () => { | ||
@@ -401,2 +408,3 @@ expect(a + b).toBe(expected); | ||
#### `.describe.skip(name, fn)` | ||
Aliases: `.xdescribe(name, fn)` | ||
@@ -410,3 +418,3 @@ | ||
${2} | ${1} | ${3} | ||
`.describe.skip('$a + $b', ({ a, b, expected }) => { | ||
`.describe.skip('$a + $b', ({a, b, expected}) => { | ||
test(`returns ${expected}`, () => { | ||
@@ -413,0 +421,0 @@ expect(a + b).toBe(expected); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
337
409
20442
2
1
2
+ Addedchalk@^2.0.1
+ Addedpretty-format@^23.0.1
+ Addedansi-regex@3.0.1(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedpretty-format@23.6.0(transitive)
+ Addedsupports-color@5.5.0(transitive)
- Removedsprintf-js@^1.0.3
- Removedsprintf-js@1.1.3(transitive)