Index of every page on this site: llms.txt
All skills
comet-ml avatar

/typescript-sdk

@9b3d88e
by Cometcomet-ml/opik23k stars
1,964
Run it yourself

TypeScript SDK patterns for Opik. Use when working in sdks/typescript.

Use this Skill: https://skilld.dev/gh/comet-ml/opik/typescript-sdk

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

testing.md

≈365 tokens on demand. Your agent reads this file only when SKILL.md points to it.

TypeScript SDK Testing

Test Runner

Vitest - run with npm test in sdks/typescript

Key Patterns

Always Flush Before Assertions

// Data only persists after flush
const client = new Opik();
client.trace({ name: "test" });
await client.flush();  // Required!

// Then assert
expect(mockFetch).toHaveBeenCalledWith(/* ... */);

Mock Network and Timers

import { vi } from 'vitest';

// Mock fetch for deterministic tests
vi.stubGlobal('fetch', vi.fn().mockResolvedValue(/* ... */));

// Use fake timers for batching tests
vi.useFakeTimers();
// ... do work ...
vi.advanceTimersByTime(1000);  // Trigger batch flush

Control Batching in Tests

// Option 1: Small delays
const client = new Opik({ batchDelay: 10 });

// Option 2: Advance fake timers
vi.advanceTimersByTime(1000);

// Option 3: Explicit flush
await client.flush();

Integration Testing

// Mock provider clients
const mockOpenAI = {
  chat: {
    completions: {
      create: vi.fn().mockResolvedValue({ /* response */ }),
    },
  },
};

// Assert spans recorded
expect(mockFetch).toHaveBeenCalledWith(
  expect.stringContaining('/spans'),
  expect.objectContaining({ method: 'POST' })
);

Best Practices

  • Test public API only, avoid rest_api internals
  • Mock network to keep tests deterministic
  • Assert no ERROR level logs unintentionally
  • Always flush() before checking persisted data

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning8mo4 checks · Risk SAFE
  • Gen Agent Trust Hub8mo

    The skill provides architectural and testing guidelines for the Opik TypeScript SDK. It contains documentation and code examples for developers. No security risks were identified.

  • Socket8mo

    No alerts

  • Snyk8mo

    Risk: LOW · No issues

  • Runlayer8mo

    2/2 files flagged

Signed by skilld at 9b3d88e. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub yesterday.

Activeupdated 9 months ago

README badge

README badge for comet-ml/opik/typescript-sdk