enzymejs / enzymejs/react-shallow-renderer

Feature: Add find* to gain alignment with react-test-renderer

Open
#117 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
37
Forks
14
PR merge metrics
No merged PRs in 30d

Description

It seems that react-test-renderer exports this package under `react-test-renderer/shallow` to support shallow rendering. However this package doesn't contain the low level "find" functions that make it easy to dive into a shallow component similar to `react-test-renderer`'s default export.

The ask is to implement the following functions for consistency:
- [testInstance.find()](https://reactjs.org/docs/test-renderer.html#testinstancefind)
- [testInstance.findByType()](https://reactjs.org/docs/test-renderer.html#testinstancefindbytype)
- [testInstance.findByProps()](https://reactjs.org/docs/test-renderer.html#testinstancefindbyprops)
- [testInstance.findAll()](https://reactjs.org/docs/test-renderer.html#testinstancefindall)
- [testInstance.findAllByType()](https://reactjs.org/docs/test-renderer.html#testinstancefindallbytype)
- [testInstance.findAllByProps()](https://reactjs.org/docs/test-renderer.html#testinstancefindallbyprops)

I know enzyme "provides a nicer higher-level API over the same functionality" my ask is to provide even basic low level to have alignment between shallow and deep core rendering engines.

I think we could probably just copy most of the logic for the deep renderer [here](https://github.com/facebook/react/blob/8e2bde6f2751aa6335f3cef488c05c3ea08e074a/packages/react-test-renderer/src/ReactTestRenderer.js#L355) and it should get us 80% of the way.

Then in the future Enzyme could update to use these lower level functions to help fuel it's higher level functions.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.