Module does not work with node.js
Opened this issue · 3 comments
tiagofassoni commented
This module does not work with node.js because node doesn't have window or navigator objects.
I made a fork of the repo and modified the module so that it checks for the existence of those objects and, if they don't exist, attaches two objects under node.js global module.
Is there any interest in an PR?
Trufi commented
@tiagofassoni Yes, it will be great
trygve-lie commented
@tiagofassoni Any chance you can submit a PR on your change? I would like to see this supported.
andrewharvey commented
This is the code I used to get it working in node.js
// window and navigator globals need to be set for mock-geolocation
global.window = {};
global.navigator = {};
const geolocation = require('mock-geolocation');
geolocation.use();
// assign the mock geolocation to window
global.window.navigator = global.navigator;
window.navigator.geolocation = global.window.navigator.geolocation;