![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@anshulsanghi/googlemaps-vitest-mocks
Advanced tools
## Forked from https://github.com/googlemaps/js-jest-mocks
Vitest mocks for Google Maps in TypeScript.
Note: If you find a missing mock, please open an issue.
Available via NPM as the package @anshulsanghi/googlemaps-vitest-mocks
You can inspect what happens with the created mock instances (e.g. Map
or Marker
) via the mockInstances
object.
import {
initialize,
Map,
Marker,
mockInstances,
} from "@anshulsanghi/googlemaps-vitest-mocks";
beforeEach(() => {
initialize();
});
test("my test", () => {
const map = new google.maps.Map(null);
const markerOne = new google.maps.Marker();
const markerTwo = new google.maps.Marker();
map.setHeading(8);
markerOne.setMap(map);
markerTwo.setLabel("My marker");
const mapMocks = mockInstances.get(Map);
const markerMocks = mockInstances.get(Marker);
expect(mapMocks).toHaveLength(1);
expect(markerMocks).toHaveLength(2);
expect(mapMocks[0].setHeading).toHaveBeenCalledWith(8);
expect(markerMocks[0].setMap).toHaveBeenCalledTimes(1);
expect(markerMocks[1].setLabel).toHaveBeenCalledWith("My marker");
});
Whenever initialize()
is called, the captured mocks are automatically cleaned. Using any of Vitest's methods, you can clean the mock instances at any time:
import {
initialize,
Map,
Marker,
mockInstances,
} from "@anshulsanghi/googlemaps-vitest-mocks";
beforeAll(() => {
initialize();
});
// Clear all mocks
beforeEach(() => {
mockInstances.clearAll();
});
// Clear specific mocks
beforeEach(() => {
mockInstances.clear(Map, Marker);
});
This library is community supported. We're comfortable enough with the stability and features of the library that we want you to build real production applications on it.
If you find a bug, or have a feature suggestion, please log an issue. If you'd like to contribute, please read How to Contribute.
FAQs
## Forked from https://github.com/googlemaps/js-jest-mocks
We found that @anshulsanghi/googlemaps-vitest-mocks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.