Unexpected behavior with legacy context (both shallow and mount)
- Dominant language
- JavaScript
- Stars
- 19.8k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
### Current behavior
Cannot test legacy context behavior (mount and shallow, on the providing and on the consuming component) → `.context` either throws or returns an empty context depending on how it's used.
### Expected behavior
`.context` returns the context somehow (after `.dive` or not, I'm not positive what the correct behavior should be)
### Your environment
Original issue was on React 16.2. Reproduction on React 16.8: https://codesandbox.io/s/oqo7nvxp2q (Notice the app works but the tests fail)
#### API
- [x] shallow
- [x] mount
- [ ] render
#### Version
| library | version
| ------------------- | -------
| enzyme | 3.9.0
| react | 16.8.6
| react-dom | 16.8.6
| react-test-renderer | N/A
| adapter (below) | 1.12.1 (react-16)
#### Adapter
- [x] enzyme-adapter-react-16
- [ ] enzyme-adapter-react-16.3
- [ ] enzyme-adapter-react-16.2 (← also the case here, but not for the above code sandbox)
- [ ] enzyme-adapter-react-16.1
- [ ] enzyme-adapter-react-15
- [ ] enzyme-adapter-react-15.4
- [ ] enzyme-adapter-react-14
- [ ] enzyme-adapter-react-13
- [ ] enzyme-adapter-react-helper
- [ ] others ( )
Contributor guide
Research direction
Start with the linked CodeSandbox reproduction and compare `.context` behavior for shallow and mount, on both providing and consuming components. Read the React 16 adapter and existing traversal tests for related context handling. Done means the expected legacy-context behavior is decided, reproduced in regression tests, and no longer throws or returns an unexpectedly empty context.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- frontend, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100