cypress-each
Advanced tools
Comparing version 1.8.0 to 1.9.0
{ | ||
"name": "cypress-each", | ||
"version": "1.8.0", | ||
"version": "1.9.0", | ||
"description": "Simple implementation for describe.each and it.each", | ||
@@ -5,0 +5,0 @@ "main": "src", |
@@ -191,2 +191,11 @@ # cypress-each ![cypress version](https://img.shields.io/badge/cypress-9.0.0-brightgreen) [![renovate-app badge][renovate-badge]][renovate-app] [![ci](https://github.com/bahmutov/cypress-each/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/bahmutov/cypress-each/actions/workflows/ci.yml) | ||
## Custom filter predicate | ||
You can filter the items by passing a predicate function | ||
```js | ||
it.each(items, (x, k) => ...) | ||
// creates a test for every item the predicate returns a truthy value | ||
``` | ||
## Exclusive tests | ||
@@ -193,0 +202,0 @@ |
@@ -6,2 +6,3 @@ // types for it.each and describe.each | ||
type TestTitleFn<T> = (item: T, index: number, items: T[]) => string | ||
type ItemPredicateFunction<T> = (item: T, index: number, items: T[]) => boolean | ||
@@ -16,3 +17,3 @@ declare namespace Mocha { | ||
* @param values Input items to create the tests form OR number of times to repeat a test | ||
* @param totalChunks (Optional) number of chunks to split the items into | ||
* @param totalChunks (Optional) number of chunks to split the items into, or Nth filter, or a predicate function | ||
* @param chunkIndex (Optional) index of the chunk to get items from | ||
@@ -24,3 +25,3 @@ * @example it.each([1, 2, 3])('test %K', (x) => ...) | ||
values: T[] | number, | ||
totalChunks?: number, | ||
totalChunks?: number | ItemPredicateFunction<T>, | ||
chunkIndex?: number, | ||
@@ -27,0 +28,0 @@ ): (titlePattern: string | TestTitleFn<T>, fn: TestCallback<T>) => void |
@@ -75,2 +75,5 @@ /// <reference types="cypress" /> | ||
values = values.filter((_, k) => k % totalChunks === 0) | ||
} else if (typeof totalChunks === 'function') { | ||
// filter using the given predicate | ||
values = values.filter(totalChunks) | ||
} | ||
@@ -77,0 +80,0 @@ |
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
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
16942
168
316