`.type` dont work with `datetime-local` inputs
See original GitHub issue@testing-library/user-event
version:13.1.9
- Testing Framework and version:
jest 27.0.5
- DOM Environment:
jsdom
(default jest version)
Relevant code or config
import '@testing-library/jest-dom/extend-expect'
import {render, screen} from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import React from 'react'
const Input = () => {
return <input type="datetime-local" data-testid="input" />
}
test('works properly', () => {
render(<Input />)
const value = '2000-01-01T00:00'
const elInput = screen.getByTestId('input')
expect(elInput).toBeVisible()
expect(elInput).toBeEnabled()
expect(elInput).toHaveValue('')
userEvent.type(elInput, value)
expect(elInput).toHaveValue(value)
})
What you did: tried to type a date to the datetime input
What happened: no date has been entered on the input
Reproduction repository: https://codesandbox.io/s/gifted-kapitsa-dfhst?file=/main.test.js
Problem description:
Suggested solution: I’ve seen previous similar issues (for date
or time
inputs), and I think it’s just a matter to include a branch logic for datetime-local
inputs.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:5 (3 by maintainers)
Top Results From Across the Web
<input type="datetime-local"> - HTML - MDN Web Docs
A string representing the value of the date entered into the input. The format of the date and time value used by this...
Read more >html - Input type DateTime - Value format? - Stack Overflow
<input type="datetime-local" name="dtl" step="7200"> Because datetime steps through one minute at a time, you may want to change the default increment by using ......
Read more >Using the input datetime-local - Andrea Giammarchi
As you probably know already, in order to avoid awkward and confusing user experience due time zones, the input type datetime has been...
Read more >Blazor input type datetime-local doesn't trigger @onchange in ...
If an input of the type "datetime-local" is used, the @onchange event is not triggered under Firefox. Firefox' console shows Uncaught Error: ...
Read more >HTML input type="datetime-local" - W3Schools
The <input type="datetime-local"> defines a date picker. The resulting value includes the year, month, day, and time. Tip: Always add the <label> tag...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Fox32 With consistent behavior across browsers we might consider an implementation. An issue collecting information on the browser behavior and discussing possible implementations would be welcome. The UI representation as used by the browser is not programmatically available. So an implementation would need to fill the gap between the (perceived) user interaction and the IDL properties.
Looks like Firefox has support nowadays (https://bugzilla.mozilla.org/show_bug.cgi?id=1283388) and behaves similar to Chrome. Can we have another look at this issue?