question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`submit()` helper

See original GitHub issue

I would like to propose adding a submit() test helper since submitting forms seems like a regular thing that is done in tests. We currently have two options:

  1. click() on a type="submit" button
  2. use triggerEvent(..., 'submit')

but they are not entirely obvious and not specific to forms. Having a dedicated submit() helper would make this a lot easier and could also add assertions on whether the passed selector actually belongs to a form, etc.

async function submit(selector) {
  await triggerEvent(selector, 'submit');
}

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
amk221commented, May 22, 2019

+1 for this.

I know I can use triggerKeyEvent('button', 'keydown', 13) and triggerEvent('form', 'submit'), but I specifically need to test that pressing enter when a text field is focused will submit the form (i.e. browser’s default behaviour)… But triggerEvent('input', 'keydown', 13) will not accomplish that - well it does in the app, but not in the test suite.

1reaction
Turbo87commented, May 8, 2019

What user interaction is being emulated by the helper? I assume that its effectively clicking on a submit button, right?

that, or pressing <kbd>Enter</kbd> in a form input

What should the selector point to? A form? The button?

the form, same as for the raw triggerEvent() helper

Read more comments on GitHub >

github_iconTop Results From Across the Web

Play Submissions Helper | Insane compendium of 400+ play ...
This Master List contains over 400 highly organized play submission opportunities around the country, seeking submissions RIGHT NOW, along with their submission ......
Read more >
submit (ActionView::Helpers::FormBuilder) - APIdock
Add the submit button for the given form. When no value is given, it checks if the object is a new resource or...
Read more >
paulzi/paulzi-form: JavaScript form helpers - GitHub
It provides the ability to send the form via AJAX, including forms with files. When submitting a form with input[type="file"] used XMLHttpRequest 2...
Read more >
.submit() | jQuery API Documentation
An object containing data that will be passed to the event handler. ... A function to execute each time the event is triggered....
Read more >
<input type="submit"> - HTML: HyperText Markup Language
An <input type="submit"> element's value attribute contains a string which is displayed as the button's label. Buttons do not have a true value ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found