Skip to content

Figure out a way to mock web service responses in tests #20

@thatbudakguy

Description

@thatbudakguy

One of the most frustrating things about the existing viewer tests in GeoBlacklight is that some of them rely on external services, like GeoServers that belong to other institutions, to be live and responsive during the test. This often fails: there are blips in connectivity, layers get pulled from the GeoServer, links rot, etc.

What would be ideal is a test suite that has no dependencies on external services when it does things like render a layer over WMS. There are at least two ways to achieve this:

  • Use some kind of tool to record/replay or mock the actual request. Note that these will be client-side requests, which is a little tricky because you have to hook into the (possibly headless) browser being used to execute the test. Worth exploring what options there are for Playwright, which has a great UI and is supported by Stencil.
  • Spin up a local server to handle the request. I started down this path by creating a docker-compose.yml that creates a local GeoServer container with some example data. In the context of our CI build, we could run that container and load it with additional fixture data stored in this repository, so that it could respond to WMS requests made in tests. For other kinds of requests (PMTiles? COG?) we might need to explore other options for serving locally, but the same general approach should work.

There's also the very interesting looking MapGrab, which has Playwright integration and seems specifically designed for testing maps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions