New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cypress-map

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cypress-map - npm Package Compare versions

Comparing version 1.9.0 to 1.10.0

commands/invoke-once.js

6

commands/index.d.ts

@@ -123,3 +123,9 @@ declare namespace Cypress {

table(x?: number, y?: number, w?: number, h?: number): Chainable<string[][]>
/**
* Invokes the method on the current subject.
* This is a COMMAND, not a query, so it won't retry, unlike the stock `cy.invoke`
*/
invokeOnce(methodName: string, ...args: unknown[]): Chainable<any>
}
}

1

commands/index.js

@@ -14,1 +14,2 @@ /// <reference types="cypress" />

import './table'
import './invoke-once'

2

package.json
{
"name": "cypress-map",
"version": "1.9.0",
"version": "1.10.0",
"description": "Extra Cypress query commands for v12+",

@@ -5,0 +5,0 @@ "main": "commands/index.js",

@@ -180,6 +180,19 @@ # cypress-map [![ci](https://github.com/bahmutov/cypress-map/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/bahmutov/cypress-map/actions/workflows/ci.yml) ![cypress version](https://img.shields.io/badge/cypress-12.3.0-brightgreen)

**Tip:** to get just the headings row, combine `.table` and `.its` queries
**Tip:** you can combine `cy.table` with `cy.map`, `cy.mapInvoke` to get the parts of the table. For example, the same 2x2 part of the table could be extracted with:
```js
cy.get('table')
.table()
.invoke('slice', 2, 4)
.mapInvoke('slice', 0, 2)
.should('deep.equal', [
['Cary', '30'],
['Joe', '28'],
])
```
**Tip 2:** to get just the headings row, combine `.table` and `.its` queries
```js
cy.get('table')
.table(0, 0, 3, 1)

@@ -190,2 +203,32 @@ .its(0)

To get the last row, you could do:
```js
cy.get('table').table().invoke('slice', -1).its(0)
```
To get the first column joined into a single array (instead of array of 1x1 arrays)
```js
cy.get('table')
.table(0, 1, 1) // skip the heading "Name" cell
// combine 1x1 arrays into one array
.invoke('flatMap', Cypress._.identity)
.should('deep.equal', ['Dave', 'Cary', 'Joe', 'Anna'])
```
### invokeOnce
In Cypress v12 `cy.invoke` became a query, which made working with asynchronous methods really unwieldy. The `cy.invokeOnce` is a return the old way of calling the method and yielding the resolved value.
```js
cy.wrap(app)
// app.fetchName is an asynchronous method
// that returns a Promise
.invokeOnce('fetchName')
.should('equal', 'My App')
```
See the spec [invoke-once.cy.js](./cypress/e2e/invoke-once.cy.js) for more examples.
## cy.invoke vs cy.map vs cy.mapInvoke

@@ -192,0 +235,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