-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a way to check what params was instance initialised with #223
Comments
@TomasRM2112 Please take a moment to fill out this short survey. Thank you! This is an automated message, feel free to ignore. |
@TomasRM2112 Thank you for opening this issue. 🙏
This is an automated message, feel free to ignore. |
Sorry, just saw this issue: #215 but I agree with the creator that preferably we wouldn't have to change the way we write code just to be able to test it |
If you're okay with setting up a rather verbose spy, the following could work. I haven't tested it thoroughly though. The following test passes: import {initialize, Polygon} from '@googlemaps/jest-mocks';
type PolyArgs = ConstructorParameters<typeof Polygon>;
test('Polygon', () => {
initialize();
const polySpy = jest
.spyOn(google.maps, 'Polygon')
.mockImplementation((...args: PolyArgs) => new Polygon(...args));
new google.maps.Polygon({strokeWeight: 2});
expect(polySpy).toHaveBeenCalledWith<PolyArgs>({strokeWeight: 2});
}); |
It would be a very useful addition to automatically add the spies as described in @eegli's comment for all API objects. |
It would be good if we could check what params was each instance initialised with. Similar to
toHaveBeenCalledWith
For example:
Probably not working example, but just to get the idea. After reading the code I believe there is no way of doing this at the moment?
The text was updated successfully, but these errors were encountered: