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

flaretest

v2.0.0

Published

![GitHub Actions](https://github.com/Spelldata/flaretest/workflows/Actions/badge.svg)

Downloads

6

Readme

flaretest

GitHub Actions

Cache rule testing utility for Cloudflare

Requirements

Node.js 10.x, 12.x, and 14.x

Install

$ yarn add --dev flaretest

or

$ npm install --save-dev flaretest

API

new FlareTest(hostname, options)

  • hostname: string - A hostname of the test target website
  • options.userAgents: { [userAgentName: string]: string } - User agent strings which FlareTest sends to the test target website

FlareTest.prototype.run(testconfigs)

  • testconfigs: object[] - Array of test configs
  • testconfigs[].paths: string[] - Array of paths to test
  • testconfigs[].cached: boolean - If target paths should be cached by Cloudflare edge
  • testconfigs[].redirectHttps: boolean - If it forces redirection to HTTPS URL when users open the target paths
  • testconfigs[].status: number - Expected status code
  • testconfigs[].cacheLevel: string - Expected cache level. standart, ignoreQueryString, or noQueryString. See Understand Cloudflare Caching Level for each cache levels. You need to purge cache before testing cache level, or the test may fail. Currently noQueryString is not supported yet.

throws: AssertionError when any test item is not matched with expected value.

returns: Promise<void> - a Promise object

Example

Here's an example using Jest:

const { FlareTest } = require("flaretest"); // or import FlareTest from "flaretest";

// Initialize flaretest
const flaretest = new FlareTest("example.com", {
  // User agent strings used when flaretest make access to the websites.
  // If two or more user agent strings is listed here, flaretest make accesses
  // for multiple times with each user agent strings
  userAgents: {
    desktop: "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3163.100 Safari/537.36",
    mobile: "Mozilla/5.0 (Linux; Android 7.1.2; Kingbox Build/NHG47K; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/73.0.3653.0 Safari/537.36",
  }
});

test("Cache rules", async () => {
  await flaretest.run([
    {
      paths: [
        "/foo/bar",
        "/boo",
        "/woo.css",
      ],
      cached: true,
      redirectHttps: true,
      status: 200,
    },
    {
      paths: [
        "/path-with-query",
      ],
      cached: true,
      redirectHttps: true,
      status: 200,
      cacheLevel: "standard", // or ignoreQueryString or noQueryString
    },
  ]);
}, 30000);