react-dom-testing icon indicating copy to clipboard operation
react-dom-testing copied to clipboard

New simulate syntax

Open sunesimonsen opened this issue 5 years ago • 0 comments

I'm considering to support a less verbose chaining syntax:

simulate(element)
  .click()
  .change('.input', { value: 'foobar' })
  .keyUp({ data: { keyCode: 13 } })
  .click('.close')

I think we should keep supporting the current syntax for compatibility, but make this syntax that is shown in the documentation by default.

I think we should do some overloading for convenience:

simulate(element)
  .<event>(<target selector>)
  .<event>(<event options>)
  .<event>(<target selector>, <event options>)

We should be able to get all of the events from React Simulate the following why:

Object.keys(Simulate).forEach(key => {
  if (typeof Simulate[key] === 'function') {
    // add even method
  }
})

If we do this, we should probably make a codemod to upgrade consumer code.

sunesimonsen avatar Nov 20 '19 20:11 sunesimonsen