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

testmo-api-client

v1.0.0

Published

Official TypeScript SDK for the Testmo API - Automation runs, threads, and test results

Readme

Testmo API Client

npm version License: MIT

Official TypeScript SDK for the Testmo API. Manage automation runs, threads, and test results programmatically.

Installation

npm install testmo-api-client

Quick Start

import { TestmoClient } from 'testmo-api-client';

const client = new TestmoClient({
  baseUrl: 'https://your-org.testmo.net',
  apiToken: process.env.TESTMO_API_TOKEN!
});

// Create an automation run
const { id: runId } = await client.automationRuns.create(projectId, {
  name: 'CI Build #123',
  source: 'backend',
  tags: ['nightly', 'regression']
});

// Create a thread and submit test results
const { id: threadId } = await client.threads.create(runId);

await client.threads.append(threadId, {
  tests: [
    { name: 'test_login', status: 'passed', elapsed: 1500000 },
    { name: 'test_checkout', status: 'failed', fields: [
      { name: 'Error', type: 4, value: 'Timeout', is_highlight: true }
    ]}
  ]
});

// Complete thread and run
await client.threads.complete(threadId);
await client.automationRuns.complete(runId, { measure_elapsed: true });

API Reference

TestmoClient

new TestmoClient({
  baseUrl: string,     // Your Testmo instance URL
  apiToken: string,    // API token for authentication
  timeout?: number     // Request timeout in ms (default: 30000)
})

Automation Runs

List runs

const runs = await client.automationRuns.list(projectId, {
  page: 1,
  per_page: 100,
  status: '3',           // Filter by status (2=success, 3=failure, 4=running)
  created_after: '2024-01-01T00:00:00.000Z',
  expands: 'automation_sources,configs,users'
});

Get a run

const run = await client.automationRuns.get(runId, {
  expands: 'automation_sources,users'
});

Create a run

const { id } = await client.automationRuns.create(projectId, {
  name: 'Run Name',
  source: 'frontend',     // Auto-created if doesn't exist
  config: 'Chrome',       // Optional configuration
  milestone: 'v2.0',      // Optional milestone
  tags: ['smoke', 'ci'],
  artifacts: [{
    name: 'build-log.txt',
    url: 'https://storage.example.com/logs/build.txt',
    mime_type: 'text/plain',
    size: 1024
  }],
  fields: [{
    name: 'Build Number',
    type: 1,
    value: '12345'
  }],
  links: [{
    name: 'CI Build',
    url: 'https://ci.example.com/build/123'
  }]
});

Append to a run

await client.automationRuns.append(runId, {
  artifacts: [{ name: 'log.txt', url: 'https://...' }],
  fields: [{ name: 'Duration', type: 1, value: '5m' }],
  links: [{ name: 'Report', url: 'https://...' }]
});

Complete a run

await client.automationRuns.complete(runId, {
  measure_elapsed: true  // Auto-calculate execution time
});

Threads

Create a thread

const { id: threadId } = await client.threads.create(runId, {
  elapsed_observed: 600000000,  // 10 minutes in microseconds
  artifacts: [{ name: 'thread-log.txt', url: 'https://...' }]
});

Submit test results

await client.threads.append(threadId, {
  elapsed_observed: 120000000,
  tests: [
    {
      key: 'unique-test-hash',      // Optional unique identifier
      name: 'test_user_creation',
      folder: 'Users',
      status: 'passed',
      elapsed: 60000000,            // Microseconds
      file: 'users.test.js',
      line: 100,
      assertions: 5,
      artifacts: [{
        name: 'screenshot.png',
        url: 'https://storage.example.com/screenshot.png'
      }]
    },
    {
      name: 'test_user_deletion',
      folder: 'Users', 
      status: 'failed',
      fields: [{
        name: 'Error',
        type: 4,
        value: 'AssertionError: expected 200 but got 500',
        meta: { type: 'AssertionError' },
        is_highlight: true
      }]
    }
  ]
});

Complete a thread

await client.threads.complete(threadId, {
  elapsed_observed: 600000000,
  elapsed_computed: 580000000
});

Error Handling

import { TestmoApiError, TestmoNetworkError, TestmoConfigError } from 'testmo-api-client';

try {
  await client.automationRuns.get(999999);
} catch (error) {
  if (error instanceof TestmoApiError) {
    console.error(`API Error: ${error.statusCode} - ${error.message}`);
    console.error('Response:', error.response);
  } else if (error instanceof TestmoNetworkError) {
    console.error(`Network Error: ${error.message}`);
  } else if (error instanceof TestmoConfigError) {
    console.error(`Config Error: ${error.message}`);
  }
}

Types

All TypeScript types are exported for your convenience:

import type {
  AutomationRun,
  TestResult,
  Artifact,
  Field,
  Link,
  PaginatedResponse,
  CreateAutomationRunParams,
  AppendToThreadParams,
} from 'testmo-api-client';

Field Types

| Type | Description | |------|-------------| | 1 | String | | 2 | Integer | | 3 | Boolean | | 4 | Text/Multiline |

Test Status Values

| Status | Description | |--------|-------------| | 2 | Success | | 3 | Failure | | 4 | Running |

Requirements

  • Node.js >= 18.0.0 (uses native fetch)

License

MIT © MAkhamis