Enzyme: .slice(begin, [end]) => Wrapper

Created on 2 Nov 2016  路  2Comments  路  Source: enzymejs/enzyme

.slice(begin[, end]) => Wrapper

Returns a new wrapper with a subset of the nodes of the original wrapper, according to the rules of Array.prototype.slice.

Use Case

Currently:

wrapper.find(Component).forEach((item, index) => {
  if (index < 2) return;
  // Assertions
});

This would be a nice addition:

wrapper.find(Component).slice(2).forEach((item, index) => {
  // Assertions
});
mount shallow enhancement help wanted

Most helpful comment

I'd be happy to submit a PR for this when I get some time this weekend.

All 2 comments

I like it. This seems straightforward, as long as it conforms to Array#slice.

I'd be happy to submit a PR for this when I get some time this weekend.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thurt picture thurt  路  3Comments

heikkimu picture heikkimu  路  3Comments

ahuth picture ahuth  路  3Comments

ivanbtrujillo picture ivanbtrujillo  路  3Comments

abe903 picture abe903  路  3Comments