New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fixtureserver

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fixtureserver

A minimal testing server with eJS and ESI support

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

fixtureserver

A minimalistic testing server to easily create and serve fixtures (i.e. "simple testing pages with dummy or mock content to run tests on"). Supports edge side includes (ESI) and embedded Javascript (eJS). Only intended for use within testing setups, pipelines or development!

Setup

Install via npm (global or local)

npm install -g fixtureserver

Then either start using commandline (and optionally pass --docroot, --host and --port as arguments) ...

fixtureserver --docroot=./your-docroot --host=localhost --port=9999

... or directly require and use within your node.js application as module

const fixtureserver = require('fixtureserver');

fixtureserver.start({
  docroot: './your-docroot',
  host: 'localhost',
  port: 9999,
});

Usage

Put HTML fixture files in your docroot, then start the server and open the default location (http://localhost:8000). The fixtures can use ESI statements as well as the full feature set of embeddedJS. A simple example might look like this:

  <!doctype html>
  <html>
  <body>
    Here we include some external file:
    <%- include('_header'); -%>

    The following is an edge side include:
    <esi:include src="http://example.com/some/remote/chunk.html" />

    Let's add some more fancy embedded Javascript (anyone feels reminded of PHP? ;) ..):
    <% if (server) { %>
      <i>server-esi v<%= server.version %></i>
    <% } %>

    <%- include('_footer'); -%>
  </body>

The include files _header.ejs and _footer.ejs (the extension is omitted in the include statement) are expected relative to the fixture's location. This makes it pretty convenient to serve a generic header or footer within your fixtures.

History

This tool is based on a very quick&dirty testing setup that we needed for functionally testing a set of server-side includes (SSI). We needed a setup that allowed us to run a functional test against the finally rendered and embedded includes. It should also handle some sort of dynamic scripting to allow stuff like includes and data mocking without too much repetition. This server does exactly that.

Why we chose ESI over SSI? SSIs may not contain a domain and therefore require a fairly complex setup using a local nginx as reverse proxy. That made everything unnecessarily complicated when just testing the integration. So we finally ditched the SSI in this setup (after wasting way too much time for 3 years).

License

MIT License, (c) Rico Pfaus 2018

Keywords

FAQs

Package last updated on 22 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc