timeStamp in event created by `createEvent` is not used
See original GitHub issue@testing-library/react
version: 11.2.0- Testing Framework and version: jest-26.0.15
- DOM Environment: jsdom-16.4.0
Relevant code or config:
import { createEvent } from '@testing-library/react'
test('event uses timeStamp', () => {
const mockEvent = createEvent.click(document.body, { timeStamp: 1000000 })
expect(mockEvent.timeStamp).toBe(1000000)
})
What you did:
- used createEvent to create an event with a manipulated timeStamp
What happened:
- the created event had a native timeStamp
Reproduction:
See test case above
Problem description:
Overwriting timeStamp is one of the documented use cases for createEvent, see https://testing-library.com/docs/dom-testing-library/api-events/#createeventeventname
Suggested solution:
As a workaround, one can use Object.defineProperty(event, ‘timeStamp’, { value: 1000000 });
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
MySQL Incorrect AT value using current_timestamp with event ...
CREATE EVENT event_name ON SCHEDULE AT CURRENT_TIMESTAMP + 30 DO UPDATE test_table SET value = 0 WHERE id = 1;. It sometimes works...
Read more >create event(V4) data error - Power Platform Community
I'm trying to create a calendar for Outlook "create event(V4)". Triggered data is Dataverse. I have set "DateOnly" data type for my date....
Read more >13.1.12 CREATE EVENT Statement - MySQL :: Developer Zone
13.1.12 CREATE EVENT Statement · AT timestamp is used for a one-time event. · To repeat actions at a regular interval, use an...
Read more >Event.timeStamp - Web APIs | MDN
The timeStamp read-only property of the Event interface returns the time (in milliseconds) at which the event was created.
Read more >Class Calendar | Apps Script - Google Developers
createEvent (title, startTime, endTime, options), CalendarEvent ... date, Date, the date of the event (only the day is used; the time is ignored) ......
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 Free
Top 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
Hi, I’d like to update the doc on this
Thanks for the report.
Can you set this property with the native event API? I think browsers set this automatically i.e. you’re not supposed to be able to manipulate them with conventional APIs (https://developer.mozilla.org/en-US/docs/Web/API/Event/timeStamp).
Though
Object.defineProperty
works. I’m leaning towards following the DOM API here. I think it should be obvious from your test if you’re mocking something.