- Notifications
You must be signed in to change notification settings - Fork 468
Closed
testing-library/testing-library-docs
#827Labels
enhancementNew feature or requestNew feature or request
Description
@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 });
ivan-oj
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request