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

krepko

v0.1.0

Published

Contract-driven HTTP testing library for executable flows

Readme

KrepkoJS

Contract-driven HTTP testing library for executable flows.

KrepkoJS is not a unit testing framework. It's not classic E2E. It's a contract system that protects the logic between client and server using executable flows.

Why KrepkoJS?

  • Contract-first: Tests describe real HTTP user flows as contracts
  • CI-friendly: If a contract breaks, CI fails. No silent regressions.
  • Simple DSL: Readable by both humans and AI agents
  • Draft mode: Mark work-in-progress flows without breaking CI
  • Zero magic: Minimal, explicit, predictable

Installation

npm install krepko

Quick Start

Create a file auth.krepko.ts:

import { krepko, expect } from 'krepko';

krepko('https://api.example.com')
    .flow('User Authentication')
    .tags(['smoke', 'auth'])
    .do('Register user', async (ctx) => {
        const res = await ctx.post('/users', {
          email: '[email protected]',
          password: 'secret123',
        });
        
        res.expectStatus(201);
        res.expectBody({ email: '[email protected]' });
        
        ctx.set('userId', res.body.id);
    })
    .do('Login', async (ctx) => {
        const res = await ctx.post('/auth/login', {
          email: '[email protected]',
          password: 'secret123',
        });
        
        res.expectStatus(200);
        res.expectBody({ token: expect.string });
        
        ctx.bearer(res.body.token);
    })
    .do('Get profile', async (ctx) => {
        const res = await ctx.get('/users/me');
        
        res.expectStatus(200);
        res.expectBody({ id: ctx.getVar('userId') });
    });

Run:

npx krepko --pattern "**/*.krepko.ts"

Output:

KrepkoJS v0.1.0
Base URL: https://api.example.com

Flow: User Authentication
  ✓ Register user     132ms
  ✓ Login             81ms
  ✓ Get profile       45ms

Summary:
✓ 1 flow passed
Total: 1 flow (3 steps)
Time: 0.26s

✓ Krepko держит ваш API

API

krepko(baseUrl)

Creates a new Krepko instance with the specified base URL.

krepko('https://api.example.com')

.flow(name)

Defines a new flow (test scenario).

krepko(url).flow('User Registration')

.do(stepName, callback)

Adds a step to the flow. Steps execute sequentially.

.do('Create user', async (ctx) => {
  // your code here
})

.tags(tags[])

Adds tags for filtering flows.

.flow('Auth').tags(['smoke', 'auth'])

.isDraft(reason?)

Marks flow as draft. Draft failures don't fail CI in dev or ci mode.

.flow('Experimental').isDraft('Work in progress')

Context (ctx)

HTTP Methods

ctx.get(path, headers?)
ctx.post(path, body?, headers?)
ctx.put(path, body?, headers?)
ctx.patch(path, body?, headers?)
ctx.delete(path, headers?)

State Management

ctx.set('key', value)      // Store value
ctx.getVar<T>('key')       // Retrieve value
ctx.vars                   // Get all stored values

Authentication

ctx.bearer(token)              // Set Bearer token for subsequent requests
ctx.clearAuth()            // Clear authentication

Response Assertions

expectStatus(code)

res.expectStatus(200)
res.expectStatus(201)

expectBody(partial)

Partial matching - only checks specified fields:

res.expectBody({ id: 1, status: 'active' })

Matchers

Use matchers for flexible assertions:

import { expect } from 'krepko';

res.expectBody({
  token: expect.any,        // Field exists (any value)
  id: expect.number,        // Is a number
  name: expect.string,      // Is a string
  active: expect.boolean,   // Is a boolean
  tags: expect.array,       // Is an array
  meta: expect.object,      // Is an object
  role: 'admin',            // Exact value
})

CLI

npx krepko [options]

Options

| Option | Alias | Description | Default | |--------|-------|-------------|---------| | --pattern | -p | Glob pattern for flow files | **/*.krepko.ts | | --mode | -m | Run mode: dev, ci, strict | ci | | --tags | -t | Filter by tags (comma-separated) | - | | --help | -h | Show help | - |

Modes

  • dev: Draft failures shown as warnings, exit 0
  • ci: Draft failures shown as warnings, exit 0. Non-draft failures exit 1
  • strict: Any draft or failure exits 1

Examples

# Run all flows
npx krepko

# Run specific pattern
npx krepko --pattern "flows/**/*.krepko.ts"

# Filter by tags
npx krepko --tags smoke
npx krepko --tags smoke,auth

# Strict mode (drafts fail CI)
npx krepko --mode strict

Environment Variables

KREPKO_MODE=ci        # Default mode

Exit Codes

| Code | Meaning | |------|---------| | 0 | All non-draft flows passed | | 1 | At least one non-draft flow failed (or draft in strict mode) |

Best Practices

Organize by Domain

flows/
  auth.krepko.ts
  users.krepko.ts
  payments.krepko.ts

Use Tags

.flow('Critical payment flow')
.tags(['smoke', 'payments', 'critical'])

Draft Experimental Flows

.flow('New checkout v2')
.isDraft('Waiting for backend deploy')

Share State Between Steps

.do('Create order', async (ctx) => {
  const res = await ctx.post('/orders', { item: 'book' });
  ctx.set('orderId', res.body.id);
})
.do('Get order', async (ctx) => {
  const res = await ctx.get(`/orders/${ctx.getVar('orderId')}`);
  res.expectStatus(200);
})

TypeScript

KrepkoJS is written in TypeScript and provides full type definitions.

import { krepko, expect, Context, KrepkoResponse } from 'krepko';

Requirements

  • Node.js >= 18.0.0

License

MIT