Having trouble figuring out how to post a form using jsdom and jquery. is this possible?
var form = '
';The above doesn't work for me, should it, or am I doing something wrong?
not yet, there are no default actions at this time.
This is probably much easier to implement now that I've implemented the form data algorithm (in FormData-impl.js). However the navigation after the form submission would of course still not work.
After form is submitted, how to read the response body? For example resourceLoader did not trigger anything after a submitted form in a iframe.
Form submission is not currently implemented, so it is not possible.
Any changes with this?
It looks like form submission is partially implemented. It dispatches a HTMLEvent but does not support the submit method.
Minimal reproduction
As a Mocha + Chai test:
import {JSDOM} from 'jsdom'
import {assert} from 'chai'
import sinon from 'sinon'
describe('JSDOM Form', () => {
it('submit form with button', () => {
const dom = new JSDOM(`
<form id="my-form">
<button type="submit" id="submit-button">Submit Button</button>
</form>
`, {})
const listener = sinon.stub()
dom.window.document.getElementById('my-form').addEventListener('submit', listener)
dom.window.document.getElementById('submit-button').click()
assert.isTrue(listener.called)
})
})
What is expected?
Submit works without any errors.
What happens?
Test succeeds but returns this error:
Error: Not implemented: HTMLFormElement.prototype.submit
Most helpful comment
It looks like form submission is partially implemented. It dispatches a HTMLEvent but does not support the submit method.
Minimal reproduction
As a Mocha + Chai test:
What is expected?
Submit works without any errors.
What happens?
Test succeeds but returns this error: