This error is occurring because the TouchEvent object in your test is missing the isTrusted property. The isTrusted property is a read-only property that is set by the browser and cannot be modified in a script.
To resolve this error, you can use a CustomEvent instead of a TouchEvent to simulate a touch event. Here's an example of how you can modify your code to use a CustomEvent:
javascript
expect.objectContaining(object)
matches any received object that recursively matches the expected properties. That is, the expected object is a subset of the received object. Therefore, it matches a received object which contains properties that are present in the expected object.
Instead of literal property values in the expected object, you can use matchers, expect.anything(), and so on.
test('onPress gets called with the right thing', () => {
const onPress = jest.fn();
simulatePresses(onPress);
expect(onPress).toHaveBeenCalledWith(
expect.objectContaining({
x: expect.any(Number),
y: expect.any(Number),
}),
);
});