cometchat-react-testing

Configure Vitest and Playwright tests for CometChat React UI Kit integrations.

Updated May 28, 2026
One-click install
npx skills add https://github.com/MAX5271/CometChat --skill cometchat-react-testing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cometchat-react-testing
Source: https://github.com/MAX5271/CometChat/tree/main/.claude/skills/cometchat-react-testing
Command: npx skills add https://github.com/MAX5271/CometChat --skill cometchat-react-testing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill solves flaky or misleading test suites for CometChat React UI Kit integrations by giving a consistent, production-aligned testing blueprint for unit, component, and end-to-end chat flows.

Core Features & Use Cases

  • Vitest + React Testing Library foundation: Provides a jsdom test environment setup, cleanup discipline, and common browser API polyfills (WebSocket, matchMedia) so UI tests run reliably.
  • Deterministic SDK mocking: Defines a canonical hoisted mock for @cometchat/chat-sdk-javascript and @cometchat/chat-uikit-react, enabling reliable init/login/render behavior tests without real network calls.
  • Chat-specific safety assertions: Includes rules that validate init ordering, verify visible error UI on failures (including red/error styling checks), ensure no Auth Key leakage in test-adjacent source, and confirm css-variables.css is imported exactly once.
  • Playwright e2e chat smoke tests: Adds a two-user messaging smoke test and CI-friendly configuration to validate real chat behavior over WebSocket.
  • Use Case: When upgrading CometChat UI Kit or migrating frameworks (Vite/Next.js/Astro), use this Skill to quickly establish reliable regression coverage for core chat flows and catch integration breaks early.

Quick Start

Use the cometchat-react-testing Skill to generate a Vitest setup, shared SDK mocks, and one Playwright two-user chat smoke test for your project’s existing CometChat integration.

Frequently Asked Questions about cometchat-react-testing

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

FAQPage Schema
How do I stop CometChat React UI Kit tests from rendering before initialization completes?

CometChat React UI Kit tests require strict init-before-render gating to prevent flaky renders. You can enforce this ordering using deterministic hoisted mocks for the SDK and component-level assertions that verify UI elements remain hidden until initialization succeeds.

How do I mock the CometChat SDK in Vitest without making real network calls?

Mocking the CometChat SDK in Vitest requires a canonical hoisted mock for @cometchat/chat-sdk-javascript and @cometchat/chat-uikit-react. This setup isolates init, login, and render behavior tests in a jsdom environment, ensuring reliable unit and component validation without WebSocket connections.

Does this testing approach support Next.js, Astro, and React Router alongside Vite?

Yes, this testing approach supports Vite, Next.js, Astro, and React Router projects. The blueprint uses Vitest and React Testing Library for unit and component testing, while Playwright handles end-to-end chat smoke tests across these frameworks to validate real message delivery.

What is the best way to run Playwright e2e chat smoke tests in CI without leaking Auth Keys?

Running Playwright e2e chat smoke tests in CI requires dedicated test credentials kept separate from source code to prevent Auth Key leakage. The configuration validates real WebSocket messaging behavior between two users while keeping sensitive keys out of the repository.

Why does my CometChat component test fail when css-variables.css is imported multiple times?

CometChat component tests fail or behave inconsistently when css-variables.css is imported multiple times. The testing blueprint includes specific safety assertions to confirm the stylesheet is imported exactly once, preventing style injection conflicts during jsdom rendering.

How do I verify visible error UI when CometChat login or initialization fails in React tests?

Verifying visible error UI for CometChat failures requires chat-specific assertions using React Testing Library. The tests check that failure states render visible error components, including specific red or error styling checks, ensuring users receive clear feedback when SDK initialization or login encounters errors.