Simulate does not merge arguments correctly
- Dominant language
- JavaScript
- Stars
- 19.8k
- Forks
- 2k
- PR merge metrics
- No merged PRs in 30d
Description
I am using enzyme 2.9.1 (and jest, if this might be somehow connected to the issue), and I am trying to test something that involves a checkbox. But IMO the second parameter of the `simulate` method doesn't work correctly... I have narrowed it down to the following code:
```javascript
const test = mount( console.log(e.currentTarget.checked)} />);
test.find('input').simulate('change', {currentTarget: {checked: true}});
```
The `console.log` here should print `true` IMO, but it actually prints `false`. It feels like the second parameter of the `simulate` call are merged in the wrong way, because the following prints `true` as I would expect:
```javascript
const test = mount( console.log(e.checked)} />);
test.find('input').simulate('change', {checked: true});
```
Am I doing something wrong, or is that really a bug?
Contributor guide
Research direction
Start by reproducing the issue with the two checkbox examples in the issue, then inspect how simulate handles and merges its event argument. Done means the change handler receives currentTarget.checked as true when simulate is called with that nested value, while preserving the direct checked behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100