testing

Automate Mocha, Chai, and MSW tests for B2C CLI commands.

51|16|Updated Oct 31, 2025
One-click install
npx skills add https://github.com/SalesforceCommerceCloud/b2c-developer-tooling --skill testing-salesforcecommercecloud
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: testing
Source: https://github.com/SalesforceCommerceCloud/b2c-developer-tooling/tree/main/.claude/skills/testing
Command: npx skills add https://github.com/SalesforceCommerceCloud/b2c-developer-tooling --skill testing-salesforcecommercecloud

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill standardizes and automates testing for the B2C CLI project, ensuring reliable releases by providing a cohesive Mocha, Chai, and MSW-based testing approach.

Core Features & Use Cases

  • Mocha-based unit and integration tests for CLI commands
  • Chai assertions with consistent testing patterns
  • MSW for deterministic HTTP request mocking and isolation
  • Test organization mirroring the source structure for easy onboarding

Quick Start

Install dependencies with pnpm install and run tests with pnpm test. For package-specific testing, use pnpm --filter @salesforce/b2c-tooling-sdk run test.

Frequently Asked Questions about testing

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

FAQPage Schema
How do I set up Mocha and Chai tests for a TypeScript CLI project?

To set up Mocha and Chai tests for a TypeScript CLI, configure the testing framework to mirror your source structure. This standardizes unit and integration tests across CLI commands using consistent assertion patterns.

What is the best way to mock HTTP requests in CLI integration tests?

Mocking HTTP requests in CLI integration tests is best handled using MSW (Mock Service Worker). MSW provides deterministic HTTP request mocking and isolation, ensuring reliable test outcomes without live network dependencies.

Can I use pnpm workspaces to run tests for specific CLI packages?

You can use pnpm workspaces to run tests for specific CLI packages by filtering. Running pnpm --filter with the package name and test script isolates package-specific testing within the workspace configuration.

Does the B2C CLI testing approach support test isolation for unit and integration tests?

The B2C CLI testing approach supports test isolation for unit and integration tests using MSW and Sinon. This ensures deterministic HTTP request mocking and reliable test execution across TypeScript environments.

Why use c8 for code coverage in a TypeScript Mocha testing setup?

Using c8 for code coverage in a TypeScript Mocha testing setup provides accurate coverage metrics for CLI commands. It integrates with the pnpm workspace configuration to report on unit and integration test execution.