GithubHelp home page GithubHelp logo

mapbox / mapbox-gl-js-mock Goto Github PK

View Code? Open in Web Editor NEW
25.0 78.0 35.0 74 KB

A maybe-some-day-fully-featured mock for mapbox-gl-js

License: BSD 3-Clause "New" or "Revised" License

JavaScript 100.00%

mapbox-gl-js-mock's Introduction

mapbox-gl-js-mock

CircleCI

A maybe-some-day-fully-featured mock for mapbox-gl-js

Work on this is on a need come basis. As we find ourselves writing tests for Mapbox Studio and mapbox maintained mapbox-gl extensions we make this better. If you have a feature in mapbox-gl-js that you want supported here, please feel free to create an issue or open a PR.

mapbox-gl-js-mock's People

Contributors

derekxm avatar mcwhittemore avatar ryanhamley avatar samanpwbb avatar sbma44 avatar scothis avatar stdavis avatar tcandens avatar tmcw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mapbox-gl-js-mock's Issues

Real queryRenderedFeatures

#5 implements a rudimentary mock of queryRenderedFeatures but this has a bunch of problems such as not caring about what features are rendered or how they are rendered...

Depending on #6 we might be able to get the real functionality, but if that isn't possible making queryRenderedFeatures work correctly would be a big help.

A mock for non-browser enviorments

When I started this lib there wasn't a known way to run mapbox-gl-js in a non-web-gl browser environment and so I had this mock only mock mapbox-gl-js functionality. Now that there is a solution for running mapbox-gl-js in a non-web-gl environment, should this mock look into being for Node.js only?

Some questions to answer.

  • Does it come with browser mocking?
  • Can we move away from mocking the mapbox-gl-js to mocking parts of the browser that mapbox-gl-js needs that aren't in normal browser mocks?
  • Are there more feature complete browser mocks than mock-browser that could render this unneeded with the mock-gl-context option?

/cc @davidtheclark @scothis

Implement/mock map.resize

map.resize() isn't implemented, would be nice to just call getBoundingClientRect on the container, and then mock out getBoundingClientRect in a way that it could be replaced by sinon or something.

Please publish 1.0.3 to npm

Version 1.0.3 includes a fix that I need since I'm calling new LatLngBounds(), but it's not available on npm.

In the meantime, I am using "mapbox-gl-js-mock": "https://github.com/mapbox/mapbox-gl-js-mock/archive/v1.0.3.tar.gz", in my package.json, but would much prefer to use 1.0.3 from the normal registry.

Thanks for writing this library!

Jest | TypeError: window.URL.createObjectURL is not a function

I'm aware that there are solutions like this but due to me being new to this I fail to completely comprehend what I should do to solve.

I don't have any setupTest.js or jest.stubs.js

Creating them appears to do nothing for my test suites. I'm using ftw-hourly for this project and I added mapbox-gl and @mapbox/mapbox-gl-geocoder as dependencies.

Can someone guide me on how to solve this?

Remove flow types from the npm distribution

When I add mapbox-gl-js-mock to my project to a create-react-app project, I expect to be able to run unit tests that involve Mapbox types.

I add the mock as a dev dependency:

yarn add --dev mapbox-gl-js-mock

I then use it as a mock in my jest tests:

jest.mock("mapbox-gl", () => require("mapbox-gl-js-mock"));

Finally, I see failing tests because the Flow type annotations confuse Jest.

/node_modules/mapbox-gl-js-mock/node_modules/mapbox-gl/src/geo/lng_lat.js:24
        lng: number;
           ^
    SyntaxError: Unexpected token :

Unfortunately, Jest does not apply transformations to files in node_modules/, so I don't see a good way around this issue shy of updating the mock to not have type annotations. Any configuration suggestions that solve the problem would be great.

For what it's worth, the create-react-app typescript integration works just fine, but the workings of that are hidden in the react-scripts. After following the suggestions for enabling flow in create-react-app, I still have this issue.

ES5 to npm

Would it be possible to transpile to ES5 before publishing to npm?

Use mapbox dist instead of src?

The references in map.js to the mapbox-gl/src folder will not work in TypeScript environments and etc where babel/flow compilation does not take place. Can you reference the mapbox-gl/dist code instead?

npm install fails.

npm install is currently failing due to outdated dependency range for mapbox-gl (and its dependency on a version of gulp-sourcemap which no longer exists in the registry).

Instructions on how to use?

Not really sure how to use this plugin with Jest. I installed it and hoping the following error would go away...

TypeError: window.URL.createObjectURL is not a function

But the error still exist...

mapbox-gl dependency is stuck at 0.44.1 - can we have an update to keep it in line?

I forked this module to see if an update to mapbox-gl version 0.51.0 might be feasible (it's currently 0.44.1 in package.json).

This would be good because 0.51.0 fixes a problem between mapbox-gl and jsdom which also crops up when testing with mapbox-gl-js-mock.

Two issues emerged with my attempted update to 0.51.0 and I didn't go further so there may be more.
For example:

TypeError: Evented is not a constructor
at new Map (node_modules/mapbox-gl-js-mock/classes/map.js:53:19)

This is because /src/util/evented.js from mapbox-gl originally exported just one object with:
module.exports = Evented;

now it exports three separate classes, one of which is called Evented.
If you fix that, it fails again with a similar problem on another class (LatLng).

An update to keep up with mapbox-gl would be much appreciated. Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.