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

@xec-sh/testing

v0.11.1

Published

Docker, SSH, and kind test fixtures for Xec integration tests

Downloads

711

Readme

@xec-sh/testing

Test infrastructure for the Xec packages: managed SSH test containers, kind cluster management for Kubernetes tests, binary detection, and conditional test helpers. Used by the integration suites in this repository; published so the suites can run from an installed package as well.

npm install -D @xec-sh/testing

SSH test containers

The package manages a fixed fleet of seven SSH containers, one per package manager, defined in DOCKER_CONTAINERS: ubuntu-apt, centos7-yum, fedora-dnf, alpine-apk, manjaro-pacman, ubuntu-brew, ubuntu-snap (ports 2201-2207).

import { $ } from '@xec-sh/core';
import { dockerManager, getSSHConfigByName, describeSSH } from '@xec-sh/testing';

// Start fixtures (or run `pnpm --filter @xec-sh/core docker:start` once)
await dockerManager.startContainer('ubuntu-apt');   // or startAllContainers()
dockerManager.getStatus();

// Connection details for a test
const config = getSSHConfigByName('ubuntu-apt');
// { host: 'localhost', port: 2201, username: 'user', password: 'password', ... }

// describeSSH auto-skips the block when the containers are not running
describeSSH('SSH operations', () => {
  it('executes a remote command', async () => {
    const ssh = $.ssh({
      host: config.host,
      port: config.port,
      username: config.username,
      password: config.password,
    });
    const result = await ssh`echo hello`;
    expect(result.stdout).toBe('hello\n');
  });
});

await dockerManager.stopAllContainers();

DockerContainerManager is a singleton — use the exported dockerManager instance or DockerContainerManager.getInstance(). It manages the predefined fixture containers only; it is not a general-purpose container runner.

Kubernetes via kind

import { KindClusterManager, isKindAvailable } from '@xec-sh/testing';

if (isKindAvailable()) {
  const kind = new KindClusterManager({ name: 'xec-test' });
  await kind.createCluster();
  await kind.deployTestPod('test-pod');
  // ... run tests with kind.kubectl(...) ...
  await kind.deleteCluster();
}

Detection and guards

import {
  findBinary,
  isDockerAvailable,
  isKindAvailable,
  isKubectlAvailable,
  validateShellName,
  skipInCI,
} from '@xec-sh/testing';

findBinary('docker');       // '/usr/local/bin/docker' or null — synchronous
isDockerAvailable();        // boolean
validateShellName('bash');  // ok
validateShellName('rm -rf');// throws

skipInCI(() => { /* block that must not run in CI */ });

Exports

| Export | Description | |--------|-------------| | dockerManager / DockerContainerManager | Start/stop the predefined SSH fixture containers, wait for SSH readiness | | DOCKER_CONTAINERS | The seven container definitions (name, port, package manager) | | describeSSH | describe that auto-skips when fixtures are unavailable | | getSSHConfig / getSSHConfigByName / SSH_TEST_CONFIGS | Connection configs for the fixture containers | | testEachPackageManager / testPackageManagers | Parameterised tests across the container fleet | | KindClusterManager / setupKindCluster / teardownKindCluster | kind cluster lifecycle for K8s tests | | docker / execInContainer / getContainerInfo / getContainerLogs / waitForContainer | Docker helpers for arbitrary containers | | cleanupTestContainers | Remove xec test containers | | findBinary / isBinaryAvailable / clearBinaryCache | Locate binaries on PATH (synchronous, cached) | | isDockerAvailable / isKindAvailable / isKubectlAvailable / isSshpassAvailable | Environment checks | | validateShellName / shellEscape | Shell-argument safety helpers | | skipInCI | Skip a block when running in CI |

Dependencies

One production dependency: dockerode, used by the Docker helper functions. Container lifecycle for the SSH fixtures shells out to the docker CLI.

License

MIT