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

anio-jtest

v0.5.1

Published

A small yet versatile javascript test runner.

Downloads

8

Readme

🧪 anio-jtest

A small yet versatile javascript test runner.

[!WARNING]
This project is far from production ready. API and behaviour might change without notice.

Usage: anio-jtest <project-root> [...options] [...flags] -- [...test_files]

    Possible options and their meaning:

        --runner <type>:<option>
            Tells anio-jtest to spawn a runner of type 'type'.

            Possible types:

                node:<path>
                    Spawn a node process to run test files on.
                    The path to the node binary can be specified as the option.
                    Default is "node".

                browser:<http-port>
                    Spawn a HTTP server to run test files on.
                    The port of the HTTP server can be specified as the option.
                    Default is a random free port.

            This option can be specified multiple times to create as many runners as you like.

            Example:

                anio-jtest <project_root> \
                    --runner node \
                    --runner browser:8080 \
                    --runner node:/home/runner/node/v20/bin/node

            The default is to spawn a single node process (equivalent to specifying "--runner node").

        --isolate <level>
            Specify level of isolation ; a higher value means better test isolation.

            Possible values:

                3 - isolate by test case (default and recommended, slowest)
                    Runs every test case in a separate worker.

                2 - isolate by describe block
                    Runs every describe block in a separate worker.

                1 - isolate by test file
                    Runs every test file in a separate worker.

                0 - run everything without isolation (not recommended, fastest)
                    Runs everything in a single worker.

        --parallel <n>
            Specify how many workers are spawned to run unit tests.
            This option has no effect if --isolate is 0.
            The default value is 5.

        --info-fd <n>
            Print information (in JSON format) that can be used to automate
            calls to anio-jtest on file descriptor with id <n>.

        --slow-test-threshold <n>
            Specify amount after a test is being reported as "slow".
            The default is 2500 (2.5 seconds).

        --timeout <n>
            Specify maximum amount of time a unit test can run in milliseconds.
            The default value is 5000 (5 seconds).

    Possible flags and their meaning:

        -no-randomize
            Do not randomize order of test cases.
            This is only really relevant if "--parallel 1" was specified.

        -collapsed
            Do not display extra information.

    Handling of test_files:

        If a file is specified it will be added to the session, regardless of the file extension.
        If a directory is specified it will be read recursively and only files ending in ".test.mjs" will be added to the session.
        Specifying the same test file twice will not result in the test file being added a second time.

Some things are not implemented (yet) such as test randomization, info-fd, slow-test-threshold and --isolate 2.

Test File API

//
// these two lines are basic boilerplate for a unit test file.
//
import {createTestSuite} from "anio-jtest/suite"

const {describe, test, suite} = createTestSuite(import.meta.url)

describe("this is a describe block", () => {
	test("this is a synchronous test", (expect) => {
		expect(1).toBe(1)
	})

	test("this is an asynchronous test", async (expect) => {
		expect.assertions(1)

		await (new Promise(resolve => setTimeout(resolve, 100)))

		expect(1).toBe(1)
	})
})

//
// test file must export a test suite
//
export default suite

Todo

  • Implement rest of the feature set.
  • Session Server (graphical web view), not a priority.