enzymejs / enzymejs/enzyme

simulate behavior is not as expected

Open
#218 18 comments 23 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
19.8k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

Please suggest how to fix this scenario to simulate currentTarget object :

```
let TestComponent = React.createClass({
updateField(event){
console.log(event.target.value);
console.log(event.currentTarget.value);

this.setState({
value: event.currentTarget.value
});
},

render(){
return
}
});

```

**target.value is available in the event object as expected**

```
let component = mount();
let input = component.find("input");
input.simulate("change", {target:{value:"hello"});
```

**currentTarget.value is NOT available in the event object as expected, currentTarget is a real dom object. Looks like jsdom is overwriting it?**

```
let component = mount();
let input = component.find("input");
input.simulate("change", {currentTarget:{value:"world"});
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the behavior using the mount and input.simulate("change", ...) examples in the issue, comparing the target and currentTarget event fields. Start by tracing the simulate event-handling entry point and the interaction with the real DOM object or jsdom. Done means currentTarget behavior is defined and the reported scenario either works as expected or is clearly documented with a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend, testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.