-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Labels
triage meI really want to be triaged.I really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
I'm following the example to extending mocks in an attempt to change the implementation of Map.getBounds to return a new value.
I reassign the google.maps.Map global as described using the following:
beforeEach(() => {
initialize();
google.maps.Map = class extends google.maps.Map {
getBounds(...args: Parameters<InstanceType<typeof google.maps.Map>["getBounds"]>): ReturnType<InstanceType<typeof google.maps.Map>["getBounds"]> {
// Call a mock, etc..
return new google.maps.LatLngBounds({ lat: 50, lng: 50 });
}
};
});
Yet my getBounds method is never called. Constructors are called as expected if I override them, but not other methods. Am I doing something wrong?
Additionally, when I override in this fashion, the instance is no longer available when using mockInstances.get(Map). Is that expected?
FWIW, I'm using Vitest, not Jest. But as I understand it the API is synonymous so shouldn't make a difference here.
Metadata
Metadata
Assignees
Labels
triage meI really want to be triaged.I really want to be triaged.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.