The problem with reducing the delay { delay: 0 }
is that it's there to throttle the char stream in case some event handler or validation can't handle the highest rate.
Also, if I test with the simplest input, no javascript attached
<input maxlength="2000">
the test takes 37 seconds with default delay of 10ms, but is still 24 seconds with delay of 0.
I would recommend setting 2000 chars via the val()
method and type the last
cy.get('input')
.invoke('val', stringGen(2000)) // set 2000 chars
.type('!') // add another
.invoke('val') // read the value
.should('have.length', 2000) // confirm the last did not go in
This runs in 0.6 seconds
If you have some javascript event handlers, you would need to trigger them after setting the initial 2000 chars
.trigger('change')
or
.trigger('input')
RichTextEditor
A rich text editor using <div>
to hold the text can be pre-loaded with the text()
method instead of the val()
method.
You will also need to identify the div that receives the text.
For example react-quill uses the class ql-editor
on it's primary div.
cy.get('div.ql-editor')
.invoke('text', stringGen(2000)) // set 2000 chars
.type('!') // add another
.invoke('text') // read the value
.should('have.length', 2000) // confirm the last did not go in
Timings for react-quill
{ delay: 10 }
(default) 32 seconds
{ delay: 0 }
18 seconds
preload the text 1.5 seconds