node-test-pattern

Write deterministic node:test unit and integration tests for the Teams Chat Bot notification consumer.

1|Updated Aug 22, 2025
One-click install
npx skills add https://github.com/interserver/teams-chat-bot --skill node-test-pattern
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: node-test-pattern
Source: https://github.com/interserver/teams-chat-bot/tree/main/.claude/skills/node-test-pattern
Command: npx skills add https://github.com/interserver/teams-chat-bot --skill node-test-pattern

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It removes friction and inconsistency when adding tests by giving a canonical, project-specific pattern for using node:test with the Teams Chat Bot’s notification consumer internals.

Core Features & Use Cases

  • node:test-only guardrails: Enforces a strict requirement to use node:test and not Jest/Mocha/other frameworks, matching the repository’s test runner expectations.
  • Deterministic mock setup: Provides a standard seam via _setInternalsForTest({ redis, redisBot, adapter }) plus hash-map-backed Redis, bot convref Redis mocking, and an adapter mock that records sent/updated activities.
  • Reliable workspace cleanliness: Ensures trace/log pollution is silenced by setting process.env.NOTIF_TRACE_LOG = '0' before requiring the consumer.

Quick Start

Use node-test-pattern when you need to add a new test by creating a file under test/ that ends with .test.js, following the required boilerplate and mock wiring, then run the suite with npm test.

Frequently Asked Questions about node-test-pattern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write deterministic node:test unit tests for a Teams bot notification consumer?

To write deterministic node:test unit tests for a Teams bot notification consumer, apply a canonical mocking seam using `_setInternalsForTest` with hash-map-backed Redis and adapter fakes to isolate convref fallback and notification queue logic.

How do I mock Redis and bot adapter interactions in a node:test suite?

Mock Redis and bot adapter interactions in a node:test suite by injecting hash-map-backed Redis, bot convref Redis mocks, and an adapter mock that records sent and updated activities using the `_setInternalsForTest` method.

What's the best way to silence trace logs when testing a notification consumer?

The best way to silence trace logs when testing a notification consumer is to set `process.env.NOTIF_TRACE_LOG = '0'` before requiring the consumer module, ensuring reliable workspace cleanliness and preventing log pollution.

Can I use Jest or Mocha instead of node:test for testing Teams bot notification queues?

No, you cannot use Jest or Mocha; the project enforces strict node:test-only guardrails to match the repository’s test runner expectations, requiring node:test imports and specific npm glob constraints for `.test.js` files.

Why do my node:test scenarios for ack and edit flows fail to restore internal states?

Ack and edit flow tests fail when internal states are not strictly restored; ensure you use `_setInternalsForTest` to apply deterministic mock setups and verify adapter behavior through recorded sent and updated activities.