Skip to content
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

Module does not work with node.js #2

Open
tiagofassoni opened this issue Nov 14, 2015 · 3 comments
Open

Module does not work with node.js #2

tiagofassoni opened this issue Nov 14, 2015 · 3 comments

Comments

@tiagofassoni
Copy link

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
Copy link
Contributor

Trufi commented Nov 16, 2015

@tiagofassoni Yes, it will be great

@trygve-lie
Copy link

@tiagofassoni Any chance you can submit a PR on your change? I would like to see this supported.

@andrewharvey
Copy link

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants