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 🙏

© 2026 – Pkg Stats / Ryan Hefner

jest-str

v1.0.3

Published

Jest system tests runner

Readme

jest-str (Jest System Test Runner)

jest-str is a tool to simplify setting up system tests in your application.

It automatically builds your assets, runs server, runs your tests and closes the server so you don't have to maintain that extra bit of scripting yourself.

jest-str has been written with React applications in mind. It has bundled presets for create-react-app and razzle.

Setup

First you will have to add jest-str package to your project. Don't forget to add a system tests library as well!

yarn add --dev jest-str
yarn add --dev nightmare

# this is only required if you use create-react-app preset
yarn add --dev serve

jest-str has been tested with Nightmare but it should theoretically work with any other system tests library.

After you've installed the package, please add test:system to your package.json:

"scripts": {
    // ...
    "test:system": "jest-str"
}

system-test.config.js

For jest-str to work you need to create a config file called system-test.config.js in the root directory of your project. It should look like this:

module.exports = {
  "preset": "create-react-app"
}

There are currently two presets: create-react-app and razzle. They both assume that your tests are either kept in src/__system_tests__ or that they have .system.js extension, which mirrors __tests__ and .test.js from unit tests.

If you don't use either of them or want to send a pull request with your own preset, you need to specify:

module.exports = {
  "build":  "command to build your app",
  "server": "command to run your server",
  "test":   "command to run your system tests"
}

Keep in mind that the test command should not run any other tests. System tests are by their nature slower so they should be kept in separate directory.

Extra configuration

Since there's no reliable cross-project way to determine when the server starts, jest-str implements a delay after starting server and before running tests. This delay is set to 3 seconds by default (3000 ms) but can be overriden.

You can also change the default port (4000) your application is started on during tests.

Example system-test.config.js :

module.exports = {
  "preset": "create-react-app",
  "delay": 3000,
  "port": 4000
}

Writing tests

Here's an example test that assumes you're using Nightmare and create-react-app:

import Nightmare from 'nightmare'

describe('App', () => {
  it('renders the initial app', async () => {
    const nightmare = Nightmare()
    return nightmare
      .goto('http://localhost:4000')
      .evaluate(() => document.querySelector('h1').textContent)
      .end()
      .then((header) => {
        expect(header).toMatch('Welcome to React');
      })
  });
});

Skipping rebuild step

You probably don't want to rebuild entire application every time you fix a typo in your tests. Unfortunately jest-str does not yet support watchmode.

To skip the build process, set SKIP_BUILD environment variable:

SKIP_BUILD=1 yarn run test:system

Keep in mind that you need to have your application already compiled and ready for this to work!