Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cypress-each

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cypress-each - npm Package Compare versions

Comparing version 1.13.0 to 1.13.1

4

package.json
{
"name": "cypress-each",
"version": "1.13.0",
"version": "1.13.1",
"description": "Simple implementation for describe.each and it.each",

@@ -24,3 +24,3 @@ "main": "src",

"semantic-release": "19.0.5",
"typescript": "^4.4.3"
"typescript": "^4.8.4"
},

@@ -27,0 +27,0 @@ "repository": {

@@ -313,2 +313,30 @@ # cypress-each ![cypress version](https://img.shields.io/badge/cypress-11.0.1-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)

### test case types
Note that in most cases, the `it.each(TestCases)` tries to "guess" the types from the array value to the test callback function. When you need to, use the utility types to "explain" the value array:
```ts
// two arguments
// each value is [number, string]
const toString: TestCaseObject2<number, string> = {
one: [1, '1'],
ten: [10, '10'],
}
it.each(toString)((a, b) => {
// a is a number
// b is a string
})
// three arguments
const additions: TestCaseObject3<number, number, string> = {
one: [1, 2, '3'], // a + b in string form
ten: [10, 20, '30'],
}
it.each(additions)((a, b, s) => {
expect(String(a + b)).to.equal(s)
})
```
## Specs

@@ -315,0 +343,0 @@

@@ -8,9 +8,23 @@ // types for it.each and describe.each

type TestCaseObject3<T0, T1, T2> = {
[index: string]: [T0, T1, T2]
}
type TestCaseObject2<T0, T1> = {
[index: string]: [T0, T1]
}
type TestCaseObject<T> = {
[index: string]: T
}
declare namespace Mocha {
type TestCallback<T> = (this: Context, arg0: T, arg1: any, arg2: any) => void
type TestCallbackAny = (
type TestCallback1<T0> = (this: Context, arg0: T0) => void
type TestCallback2<T0, T1> = (this: Context, arg0: T0, arg1: T1) => void
type TestCallback3<T0, T1, T2> = (
this: Context,
arg0: any,
arg1: any,
arg2: any,
arg0: T0,
arg1: T1,
arg2: T2,
) => void

@@ -47,3 +61,35 @@

*/
each(testCases: object): (fn: TestCallbackAny) => void
each<T0, T1, T2>(
testCases: TestCaseObject3<T0, T1, T2>,
): (fn: TestCallback3<T0, T1, T2>) => void
/**
* A single test case object where the keys are test titles,
* and the values are used as inputs to the test callback
* @see https://github.com/bahmutov/cypress-each#test-case-object
* @example
* const testCases = {
* // key: the test label
* // value: list of inputs for each test case
* 'positive numbers': [1, 6, 7], // [a, b, expected result]
* 'negative numbers': [1, -6, -5],
* }
* it.each(testCases)((a, b, result) => { ... })
*/
each<T0, T1>(
testCases: TestCaseObject2<T0, T1>,
): (fn: TestCallback2<T0, T1>) => void
/**
* A single test case object where the keys are test titles,
* and the single value are used as inputs to the test callback
* @see https://github.com/bahmutov/cypress-each#test-case-object
* @example
* const testCases = {
* 'two': 2,
* 'three': 3,
* }
* it.each(testCases)((a) => { ... })
*/
each<T0>(testCases: TestCaseObject<T0>): (fn: TestCallback1<T0>) => void
}

@@ -50,0 +96,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc