mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-04 22:10:40 -05:00
docs: Updated _ method & bundled tools doc to reference lodash instead of Underscore
This commit is contained in:
@@ -3,7 +3,7 @@ title: Cypress._
|
||||
comments: false
|
||||
---
|
||||
|
||||
Cypress automatically includes {% url 'Underscore' http://underscorejs.org/ %} and exposes it as `Cypress._`. Call any valid Underscore method on `Cypress._`
|
||||
Cypress automatically includes {% url 'lodash' https://lodash.com/ %} and exposes it as `Cypress._`. Call any valid lodash method on `Cypress._`
|
||||
|
||||
# Syntax
|
||||
|
||||
@@ -27,15 +27,15 @@ cy._.keys(obj) // Errors, cannot be chained off 'cy'
|
||||
|
||||
# Examples
|
||||
|
||||
## `_.each`
|
||||
## `_.forEach`
|
||||
|
||||
```javascript
|
||||
// set local reference to underscore
|
||||
// set local reference to lodash
|
||||
var _ = Cypress._
|
||||
|
||||
cy.get("li").then(function($li){
|
||||
// use the _.each function
|
||||
_.each($li.get(), function(el, i){
|
||||
// use the _.forEach function
|
||||
_.forEach($li.get(), function(el, i){
|
||||
|
||||
// use Cypress.$(...) to wrap the DOM element
|
||||
// into a jQuery object
|
||||
@@ -48,10 +48,9 @@ cy.get("li").then(function($li){
|
||||
|
||||
```javascript
|
||||
cy
|
||||
// use the _.chain, _.pluck, _.first, and _.value functions
|
||||
// use the _.chain, _.map, _.take, and _.value functions
|
||||
.request('http://jsonplaceholder.typicode.com/users').then(function(response){
|
||||
var _ = Cypress._
|
||||
var ids = _.chain(response.body).pluck('id').first(3).value()
|
||||
var ids = Cypress._.chain(response.body).map('id').take(3).value()
|
||||
|
||||
expect(ids).to.deep.eq([1, 2, 3])
|
||||
})
|
||||
|
||||
@@ -74,7 +74,7 @@ Sinon-as-Promised gives you the ability to stub methods that return Promises. To
|
||||
|
||||
Cypress also bundles the following tools on the `Cypress` object. These can be used anywhere inside of your tests.
|
||||
|
||||
- {% url `Cypress._` _ %} (Underscore)
|
||||
- {% url `Cypress._` _ %} (lodash)
|
||||
- {% url `Cypress.$` $ %} (jQuery)
|
||||
- {% url `Cypress.minimatch` minimatch %} (minimatch.js)
|
||||
- {% url `Cypress.moment` moment %} (moment.js)
|
||||
|
||||
Reference in New Issue
Block a user