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 🙏

© 2025 – Pkg Stats / Ryan Hefner

geste-test

v0.1.22

Published

<div align="center"> <img src="shots/geste-2-es.png" alt="geste" height="200" /> </div>

Readme

Features

  • Drop-in replacement to Jest
  • TypeScript and JSX support out of the box
  • Supa-fast compilation of test files
  • Support of async tests
  • Support of both ESM and CJS syntaxes
  • Built-in support of benchmark tests

Installation

npm install --save-dev geste-test

Usage

To run your whole test suite, at the root of your project:

geste

To run only specific tests:

geste tests/utils/*.ts

Available options

  • --update-snapshots: when set, failing expect.toMatchSnapshot() assertions will update corresponding snapshot files.
  • --bench: run benchmark tests right after unit tests
  • --only-bench: run only benchmark tests and ignore unit tests

Usage with tests needing a DOM

Install linkedom and (optionally) @testing-library/jest-dom:

npm install --save-dev linkedom
# optional: for usage with testing-library
npm install --save-dev @testing-library/jest-dom

Create a geste.config.ts file at the root of your project (next to package.json):

// geste.config.ts

export default {
  setupFiles: ["./setupTests.ts"],
};

Then create the setupTests.ts file, which will be ran before each one of your tests (see https://jestjs.io/docs/configuration#setupfiles-array):

// setupTests.ts

import { parseHTML } from "linkedom";
// optional: for usage with testing-library (run `npm install @testing-library/jest-dom`)
import "@testing-library/jest-dom";

const defaultHtml =
  '<!doctype html><html><head><meta charset="utf-8"></head><body></body></html>';

const dom = parseHTML(defaultHtml);
const { window } = dom;
const { document } = window;

// add missing window.location property
if (!window.location) {
  // @ts-ignore
  window.location = { protocol: "http" };
}

// add missing document.getSelection property
if (!document.getSelection) {
  // @ts-ignore
  document.getSelection = () => ({});
}

// add missing window.getComputedStyled property
if (!window.getComputedStyle) {
  // https://github.com/mikemadest/jest-environment-linkedom/blob/main/src/get-computed-style-polyfill.js
  function getComputedStyle(element) {
    this.el = element;

    this.getPropertyValue = function (prop) {
      const regExp = /(\-([a-z]){1})/g;
      let updatedProp = prop === "float" ? "styleFloat" : prop;

      if (regExp.test(updatedProp)) {
        updatedProp = updatedProp.replace(regExp, function (match, ...parts) {
          return parts[1].toUpperCase();
        });
      }

      return element?.currentStyle?.[updatedProp]
        ? element.currentStyle[updatedProp]
        : null;
    };

    return this;
  }

  window.getComputedStyle = getComputedStyle;
}

// add missing default width/height of window (1024x768 is JSDOM's default)
if (!window.innerWidth) {
  window.innerWidth = 1024;
}
if (!window.outerWidth) {
  window.outerWidth = 1024;
}
if (!window.innerHeight) {
  window.innerHeight = 768;
}
if (!window.outerHeight) {
  window.outerHeight = 768;
}

// add in global all window's properties that are not already defined
for (const key of Object.getOwnPropertyNames(window).filter(
  (k) => !k.startsWith("_") && !global[k]
)) {
  global[key] = window[key];
}

global.document = document;
global.window = window;
global.navigator = window.navigator;
window.console = global.console;

API

Test API

geste's API aims to be the exact same as Jest's:

However this is a WIP project so more APIs will be implemented in the future. Feel free to fill in an issue to ask for the APIs you'd like to be implemented in priority.

Check out the examples/ folder to see real usages of geste API.

Benchmark API

geste also implements a benchmarking API inspired by Golang's. Benchmark tests are written the same way as unit tests and are launched only when running geste with the --bench option (or --only-bench to run only benchmark tests).

benchmark: (desc: string, cb: (b: BenchmarkTools) => any) => void:

Register a benchmark test.

import { BenchmarkTools } from "geste-test";

benchmark("benchmark factorialize", (b: BenchmarkTools) => {
  for (let i = 0; i < b.N; i++) {
    factorialize(10);
  }
});

geste --bench will output something like:

tests/benchmarks.test.ts
b  benchmark factorialize     20971520     82ns/op     1714ms
  • benchmark factorialize is the name of the benchmark test
  • 20971520 is the number of times your function was able to run in (at least) one second (higher is better)
  • 82ns/op indicates how much time each run took in average (lower is better)
  • 1714ms is the execution time that was needed to run your function 20971520 times

benchmark.skip: (desc: string, cb: (b: BenchmarkTools) => any) => void

Skip a benchmark test.

benchmark.each: (cases: any[]) => (desc: string, cb: (b: BenchmarkTools, ...args: any[]) => any) => void

Register a benchmark test for each case provided. Useful to benchmark a function with various inputs.

benchmark.each([[10], [100], [1000]])("benchmark factorialize(%i)", (b, n) => {
  for (let i = 0; i < b.N; i++) {
    factorialize(n);
  }
});

Configuration

This project aims to be a drop-in replacement to Jest, so the configuration options are very much inspired by it.

You can configure geste's options by creating a geste.config.ts file at the root of your project.

These are the default configuration values:

// geste.config.ts

export default {
  testPatterns: [
    "**/__tests__/**/*.[jt]s?(x)",
    "**/?(*.)+(spec|test).[jt]s?(x)",
  ],
  ignorePatterns: ["**/node_modules/**/*"],
  setupFiles: [],
  throwOnCompilationErrors: true,
};

Here are the list of the currently supported configuration options, and their Jest's "equivalent":

  • testPatterns: array of glob patterns used to walk your project's sources and find test files. Equivalent to Jest's testMatch
  • ignorePatterns: array of glob patterns that will be ignored when looking for test files. Close to Jest's testPathIgnorePatterns but here it's a array of glob patterns instead of regexp patterns.
  • setupFiles: array of paths to modules that will be compiled and evaluated before every one of your test files. Equivalent to Jest's setupFiles
  • throwOnCompilationErrors: should geste throw if it encounters an error while compiling a test file. Kinda same as setting Jest's bail to true