mskills testing.instructions.md

Testing instructions for a TypeScript project using Vitest, a JavaScript and TypeScript test framework. They explain where tests belong, how to structure them, and how to replace file-system and terminal libraries with test doubles.

In plain words
What is it for?
Writing tests beside source files, arranging test setup and cleanup, checking results, and mocking Node.js file operations and external libraries.
Why use it?
They provide consistent testing patterns and prevent tests from changing real files or producing unwanted terminal output.

Instructions file for GitHub Copilot

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/yurakawa/mskills/testing
Clone the repo
git clone --depth 1 https://github.com/yurakawa/mskills

Made for: GitHub Copilot.

Per session 541 This file is loaded in full into every session.
When invoked 541 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00541 $0.00541
Opus 5 $0.00270 $0.00270
Sonnet 5 $0.00108 $0.00108
Haiku 4.5 $0.00054 $0.00054

Measured 2d ago against content hash aa7b57f8869b, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

mskills testing.instructions.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.github/instructions/testing.instructions.md · 106 lines

How it starts

The opening of the file, as written. The whole thing — 106 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Testing Instructions

Test Framework

This project uses Vitest for testing.

Test File Location

  • Co-locate test files with source files
  • Naming: filename.test.ts (e.g., manager.test.ts for manager.ts)

Test Structure

import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';

describe('Feature Name', () => {
  beforeEach(() => {
    // Setup
  });

  afterEach(() => {
    // Cleanup
  });

  it('should do something specific', async () => {
    // Arrange
    const input = 'test';

    // Act
    const result = await functionUnderTest(input);

    // Assert
    expect(result).toBe(expected);
  });
});

Mocking

File System Operations

When mocking Node.js built-in modules, the mock path must match the import statement. If you import with the node: protocol, use the same protocol in the mock:

// If importing with node: protocol
import fs from 'node:fs/promises';

// Mock with the same path
vi.mock('node:fs/promises', () => ({
  default: {
    readFile: vi.fn(),
    writeFile: vi.fn(),
    mkdir: vi.fn(),
    // ... other methods
  },
}));

External Libraries

Mock chalk and ora to avoid terminal output during tests:

vi.mock('chalk', () => ({
  default: {
    green: vi.fn((text) => text),
    red: vi.fn((text) => text),
    cyan: vi.fn((text) => text),
  },
}));

vi.mock('ora', () => ({
  default: vi.fn(() => ({
    start: vi.fn().mockReturnThis(),
    succeed: vi.fn(),
    fail: vi.fn(),
  })),
}));

Test Coverage

  • Test both success and error paths
  • Test edge cases (empty inputs, invalid data, etc.)
  • Verify error messages and exit codes
  • Mock external dependencies (file system, network, etc.)

Running Tests

  • Run all tests: npm test
  • Tests run automatically on build via the prepare script
  • Vitest runs in watch mode by default during development

Assertions

  • Use descriptive assertion messages
  • Prefer specific assertions (toBe, toEqual, toThrow) over generic ones
  • Test async functions with await and handle rejections appropriately

Read the full file on GitHub · 106 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 106 lines · 541 tokens per session scan A aa7b57f8869b

Subscribe to this mod's changes

mskills testing.instructions.md is an instructions file published in the GitHub repository yurakawa/mskills (3 stars, last pushed 4mo ago), licensed MIT. It adds 541 tokens to every session, about $0.0027 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.