Przejdź do treści
Biblioteka skilli
Programowanie · Testowanie

testing-flow

/testing-flow

Uruchamia i pisze testy behawioralne przepływów Robomotion przez @robomotion/sdk/testing, sprawdza pokrycie gałęzi i mockuje usługi.

Repozytorium
agent-skills ↗
Licencja
MIT
Ostatnia zmiana repozytorium
27.10.2026

Ocena i bezpieczeństwo

100/ 100Klasa: dobry
Format25 / 25
Frontmatter z nazwą i opisem, poprawna nazwa, opis do 1024 znaków, nazwa zgodna z folderem.
Odkrywalność25 / 25
Opis mówi, kiedy użyć skilla, ma sensowną długość i jest w 3. osobie.
Treść35 / 35
Co najmniej 150 słów i do 500 linii, nagłówki, listy kroków, przykłady albo kod.
Higiena15 / 15
Bez zaślepek typu TODO, bez ścieżek Windows, z licencją.
Ryzykobrak sygnałów w skanie
Pliki w paczce
7
Skrypty
0
Komentarze HTML
0
Adresy URL w SKILL.md
0
Przestarzałość

Brak sygnałów. Repozytorium zmienione 27.10.2026, bez odwołań do wycofanych modeli i API.

Licencja

MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.

Co robi i kiedy

Uruchamia i pisze testy behawioralne przepływów Robomotion przez @robomotion/sdk/testing, sprawdza pokrycie gałęzi i mockuje usługi.

Wyzwalacze z opisu

test the flowwrite tests for main.tsmock this servicecheck branch coverage
Oryginalny opis (EN)

Runs and authors behavioral tests for Robomotion flows using @robomotion/sdk/testing. Use when the user says "test the flow", "write tests for main.ts", "mock this service", "check branch coverage", or when a flow needs regression tests before a change. For pspec schema validation, use validating-flow instead.

Jak działa

  1. Purpose
  2. Workflow
  3. Quick Start
  4. API Map
  5. Complete Example
  6. Tips
  7. Related Skills
Sekcje z nagłówków SKILL.md, w oryginale · 141 linii, 531 słów
Podgląd SKILL.md
---
name: testing-flow
description: Runs and authors behavioral tests for Robomotion flows using @robomotion/sdk/testing. Use when the user says "test the flow", "write tests for main.ts", "mock this service", "check branch coverage", or when a flow needs regression tests before a change. For pspec schema validation, use validating-flow instead.
---

# Testing a Robomotion Flow

Run behavioral tests for a Robomotion flow. Uses `@robomotion/sdk/testing` + `bun test`.

**For pspec schema validation, use `validating-flow`.**

## Purpose

- Execute `*.test.ts` files with `bun test`
- Author new tests with FlowTester, MockRegistry, SubflowTester
- Inspect structure, mock services, trace execution, exercise Function-node logic

## Workflow

1. **Check for tests** — `ls path/to/flow/*.test.ts`
2. **Run** — `cd path/to/flow && bun test`
3. **Fix failures** — diagnose, edit, re-run

## Quick Start

Create `main.test.ts` next to `main.ts`:

```typescript
import { describe, test, expect, beforeAll, afterAll } from 'bun:test';
import { FlowTester, MockRegistry } from '@robomotion/sdk/testing';

describe('My Flow', () => {
  let tester: FlowTester;

  beforeAll(async () => {
    tester = await FlowTester.load('./main.ts');
  });

  afterAll(() => {
    MockRegistry.clear();
  });

  test('validates', () => {
    expect(tester.validate().valid).toBe(true);
  });

  test('has expected node count', () => {
    expect(tester.getNodes().length).toBe(10);
  });
});
```

## API Map

Load only the reference file(s) you need. Each is self-contained and lives inside this skill under `./reference/`.

| Area | What's in it | Reference |
|------|--------------|-----------|
| Load/inspect flows, run checkpoints, analyze paths and complexity | `FlowTester`, `analyzeFlow`, `findPaths`, `generateDotGraph` | `./reference/flow-tester.md` |
| Mock external services (per-node, per-type, helpers, call tracking) | `MockRegistry`, `mockResponse/Error/Sequence/Conditional` | `./reference/mock-registry.md` |
| Test Function-node JavaScript in isolation | `extractFunc`, `runFunc`, `testFunctionWithCases`, `analyzeFunctionNode` | `./reference/function-extraction.md` |
| Run subflows in isolation; discover them in a flow | `SubflowTester`, `discoverSubflows`, `loadAllSubflows` | `./reference/subflow-tester.md` |
| Unit vs real-service mode via env vars | `isIntegrationMode`, `hasCredentials`, `createTestHelper` | `./reference/integration-mode.md` |

## Complete Example

```typescript
import { describe, test, expect, beforeAll, afterAll, afterEach } from 'bun:test';
import {
  FlowTester, MockRegistry, extractFunc,
  isIntegrationMode, hasCredentials, analyzeFlow,
} from '@robomotion/sdk/testing';

describe('Reddit to WordPress Flow', () => {
  let tester: FlowTester;

  beforeAll(async () => { tester = await FlowTester.load('./main.ts'); });
  afterEach(() => MockRegistry.resetCalls());
  afterAll(() => MockRegistry.clear());

  describe('Structure', () => {
    test('validates', () => expect(tester.validate().valid).toBe(true));
    test('all branches terminate', () => expect(tester.allBranchesTerminate()).toBe(true));
    test('loops have Goto->Label', () => {
      expect(tester.findLoops().every(l => l.hasGotoLabel)).toBe(true);
    });
    test('no dead ends', () => {
      expect(analyzeFlow(tester).deadEnds).toHaveLength(0);
    });
  });

  describe('Transform Logic', () => {
    test('formats Reddit post', () => {
      const transform = extractFunc(tester, '2bf967');
      const out = transform({ post: { title: 'Test', selftext: 'Body', subreddit: 'programming' } });
      expect(out.wpTitle).toContain('Test');
    });
  });

  describe('With Mocked Services', () => {
    beforeAll(() => {
      MockRegistry.registerNode('c8f412', async () => ({
        posts: [{ title: 'Mock 1', selftext: 'c1', score: 100 }],
      }));
      MockRegistry.register('Core.Net.HttpRequest', async (p, m, nodeId) => {
        console.warn(`Unmocked HTTP in ${nodeId}`);
        return { statusCode: 200, body: {} };
      });
    });

    test('fetches posts', async () => {
      const res = await tester.runUntil('c5d901', {
        input: { subreddit: 'programming', limit: 10 },
      });
      expect(res.msg.posts).toHaveLength(1);
      expect(MockRegistry.getCallCount('c8f412')).toBe(1);
    });
  });

  describe('Integration', () => {
    test('real WordPress posting', async () => {
      if (!isIntegrationMode() || !hasCredentials('wordpress')) return;
      const res = await tester.runWithTrace({
        input: { subreddit: 'programming', postLimit: 1 },
        useRealServices: true,
      });
      expect(res.output.publishedUrl).toBeDefined();
    });
  });
});
```

## Tips

- Use node-ID mocks for precise control; type mocks as catch-all.
- Verify mock inputs with `getLastCall()`.
- Clear mocks in `afterAll()` to avoid pollution across files.
- `INTEGRATION=1 bun test` switches to real services.

## Related Skills

- `validating-flow` — schema validation (property names, ports, node types)
- `creating-flow` — generate TypeScript
- `running-flow` — execute on a robot
Pliki w paczce (7)
  • SKILL.md 5 KB
  • config.json 1 KB
  • reference/flow-tester.md 3 KB
  • reference/function-extraction.md 1 KB
  • reference/integration-mode.md 2 KB
  • reference/mock-registry.md 3 KB
  • reference/subflow-tester.md 1 KB

Wersje

W bazie nie ma innych skilli o nazwie testing-flow.

Migawka bazy z 13.11.2026 · wersja paczki 3a9cf646a324 (skrót SHA-256 całej paczki)

Pobrania w ostatnich 30 dniach: 1 · ranking

Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.

Podobne skille

  • 100validating-flow
    Waliduje skompilowany przepływ Robomotion względem schematów pspec i raportuje błędy węzeł po węźle.
  • 100creating-flow
    Tworzy przepływy automatyzacji Robomotion w builderze TypeScript @robomotion/sdk: wymagania, plan, budowa, walidacja i zapis, także z gotowego planu.
  • 100write-flow-tests
    Opisuje zasady pisania testów przepływów w Pythonie: testy zachowania end-to-end w katalogu pytests, także jako kryteria przeglądu.
  • 100vitest-testing-patterns
    Pisze testy w Vitest i React Testing Library: testy jednostkowe, komponentów i integracyjne, mockowanie zależności, pokrycie i dobre praktyki.
  • 100vitest-testing-patterns
    Pisze testy w Vitest i React Testing Library: testy jednostkowe, komponentów i integracyjne, mockowanie zależności, pokrycie i dobre praktyki.
  • 100library-testing
    Tworzy i przegląda testy biblioteki TypeScript: testy uruchomieniowe, testy typów, pokrycie regresji i walidację CLI.

Uwagi i zgłoszenia

Wiadomość trafi do Bartosza Sokolińskiego. Adres e-mail jest potrzebny tylko do odpowiedzi. Szczegóły w polityce prywatności.