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.11.0 to 1.12.0

10

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

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

"scripts": {
"lint": "tsc --pretty --allowJs --strict --noEmit src/index.js cypress/integration/*.js",
"lint": "tsc --pretty --allowJs --strict --noEmit src/index.js cypress/**/*.js",
"test": "cypress-expect run --expect cypress/expected.json",

@@ -20,7 +20,7 @@ "semantic-release": "semantic-release"

"devDependencies": {
"cypress": "9.4.1",
"cypress-expect": "2.5.1",
"cypress": "11.0.0",
"cypress-expect": "2.5.3",
"mocha-each": "^2.0.1",
"prettier": "^2.4.1",
"semantic-release": "19.0.2",
"semantic-release": "19.0.5",
"typescript": "^4.4.3"

@@ -27,0 +27,0 @@ },

@@ -1,2 +0,3 @@

# cypress-each ![cypress version](https://img.shields.io/badge/cypress-9.4.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)
# cypress-each ![cypress version](https://img.shields.io/badge/cypress-9.7.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)
> A demo of mocha-each and custom describe.each and it.each implementation for Cypress

@@ -57,4 +58,3 @@

['header', 'be.visible'],
['footer', 'exist']
['.new-todo', 'not.be.visible']
['footer', 'exist'][('.new-todo', 'not.be.visible')],
]

@@ -102,2 +102,14 @@ it.each(data)('element %s should %s', (selector, assertion) => {

You can also insert the arguments from the test callback via positions (0-based) into the title
```js
const list = [
['foo', 'main'],
['bar', 'edge'],
]
it.each(list)('testing %1 value %0')
// "testing main value foo"
// "testing edge value bar"
```
If you want to use the iteration variable in the title, use `%k` for zero-based index, or `%K` for one-based index.

@@ -127,2 +139,6 @@

Example: `it.each([10, 20, 30])('case %K: an item costs $%d.00 on sale', ...`
![Formatted test titles](./images/titles.png)
### Title function

@@ -253,2 +269,31 @@

## Run specs in parallel
See the explanation in the blog post [Refactor Tests To Be Independent And Fast Using Cypress-Each Plugin](https://glebbahmutov.com/blog/refactor-using-each/), but basically you create separate specs file, and each just uses `cypress-each` to run a subset of the tests
```js
// utils.js
export const testTitle = (selector, k) =>
`testing ${k + 1} ...`
export const testDataItem = (item) => {
...
}
// spec1.js
import { data } from '...'
import { testTitle, testDataItem } from './utils'
it.each(data, 3, 0)(testTitle, testDataItem)
// spec2.js
import { data } from '...'
import { testTitle, testDataItem } from './utils'
it.each(data, 3, 1)(testTitle, testDataItem)
// spec3.js
import { data } from '...'
import { testTitle, testDataItem } from './utils'
it.each(data, 3, 2)(testTitle, testDataItem)
```
## Specs

@@ -285,3 +330,3 @@

"compilerOptions": {
"types": ["cypress", "cypress-each"],
"types": ["cypress", "cypress-each"]
}

@@ -288,0 +333,0 @@ }

@@ -35,3 +35,3 @@ /// <reference types="cypress" />

if (typeof titlePattern === 'string') {
const testTitle = titlePattern
let testTitle = titlePattern
.replace('%k', k)

@@ -41,2 +41,8 @@ .replace('%K', k + 1)

if (Array.isArray(value)) {
// apply any positional arguments
// https://github.com/bahmutov/cypress-each/issues/50
testTitle = testTitle
.replace('%0', value[0])
.replace('%1', value[1])
.replace('%2', value[2])
return formatTitle(testTitle, ...value)

@@ -43,0 +49,0 @@ } else {

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