npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@fakehost/fake-rest

v1.0.0-beta.3

Published

A fake REST server that can run as a service or bundled within a browser, for testing and demoing

Downloads

160

Readme

@fakehost/fake-rest

NPM Version

A fake REST server that can run as a service or bundled within a browser, for testing and demoing.

This is not a production server.

Example use cases

  • For deep testing against a remote service you have very little control over
  • For creating a standalone demo application

Run your e2e tests against a controllable fake version of a remote REST service.

Ensure your fake is aligned with the remote using contract tests.

Can be run in any node environment e.g.

  • Testing with Playwright, Webdriver, Jest, Vitest
  • Testing react-native applications with react-native-testing-library

For these, as the test runner runs in a nodejs process, its just a case of starting a HttpRestService with your Router, and ensuring your application endpoint is configured to point to your fake's endpoint.

See also

See testing in Playwright for playwright setup.

See testing in cypress for cypress setup.

See bundling fakes in a web application for creating standlone demo apps, or for similar for storybook etc.

See running as a local service

Why not just mock?

Mocking is great, but tends to leave a lot of static test data around your tests. What happens if the test data no longer matches the remote service?

Why not hijack the code directly from my test environment?

I've seen many examples of test setups that do things like expose methods on the global window object that are then called from tests to control the internal behaviour.

This is fine up to a point, but a this is creating a whole new api specifically for tests, b there is no longer a contract between your test version and the real version. Its much cleaner to instead treat the network interface of your application as the interface to your test setup.

License

@fakehost/fake-rest is licensed under the MIT License.