mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-20 23:28:42 -05:00
45 lines
835 B
Markdown
45 lines
835 B
Markdown
---
|
|
title: wrap
|
|
comments: true
|
|
description: ''
|
|
---
|
|
|
|
Return the object passed into `cy.wrap`.
|
|
|
|
| | |
|
|
|--- | --- |
|
|
| **Returns** | the object passed into `cy.wrap` |
|
|
| **Timeout** | *cannot timeout* |
|
|
|
|
# [cy.wrap( *object* )](#usage)
|
|
|
|
Return the object passed into `cy.wrap`.
|
|
|
|
# Options
|
|
|
|
Pass in an options object to change the default behavior of `cy.wrap`.
|
|
|
|
**cy.wrap( *object*, *options* )**
|
|
|
|
Option | Default | Notes
|
|
--- | --- | ---
|
|
`log` | `true` | whether to display command in command log
|
|
|
|
# Usage
|
|
|
|
## Invokes the function on the subject in wrap and returns the new value.
|
|
|
|
```javascript
|
|
var fn = function(){
|
|
return 'bar'
|
|
}
|
|
|
|
cy.wrap({foo: fn}).invoke('foo').should('eq', 'bar') // true
|
|
```
|
|
|
|
# See also
|
|
|
|
- [invoke](https://on.cypress.io/api/invoke)
|
|
- [its](https://on.cypress.io/api/its)
|
|
- [then](https://on.cypress.io/api/then)
|