Logo di Cometchat Angular V5 Testing

Cometchat Angular V5 Testing

Organizzazione
cometchat
cometchat-angular-v5-testing

Test an Angular app that embeds CometChat — what to mock vs exercise for real, TestBed setup for standalone kit components, avoiding real network in unit tests, and a two-account manual pass for realtime. Triggers: 'write tests for my chat', 'mock cometchat in jest', 'testbed cometchat', 'my tests hang', 'e2e test the chat'.

Panoramica

Pubblicato dacometchat
Repositorycometchat-skills
Nome della skillcometchat-angular-v5-testing
Stelle
109
Fork
2
File inclusi
Solo istruzioni
LicenzaMIT
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da cometchat su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Cometchat Angular V5 Testing in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/cometchat/cometchat-skills/tree/main/skills/cometchat-angular-v5-testing
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/cometchat/cometchat-skills.git /tmp/cometchat-skills
mkdir -p .claude/skills
cp -r /tmp/cometchat-skills/skills/cometchat-angular-v5-testing .claude/skills/cometchat-angular-v5-testing
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Cometchat Angular V5 Testing in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Cometchat Angular V5 Testing non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Cometchat Angular V5 Testing non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Ground truth: @cometchat/chat-uikit-angular@5 (5.1.0–5.2.0 verified). The Angular UI Kit docs have no testing page — the strategy here is the pack's own, and is labelled as such rather than presented as documented (a tracked DOCS GAP). Any kit symbol a test mocks must still exist in the angular-v5 catalog, and its real shape comes from the component's .md twin via cometchat-angular-v5-core/references/docs-map.md — mock the API the kit actually exposes, never one invented to fit the test.

Companion skills (read first)

  • cometchat-angular-v5-core — init/login lifecycle, which is what makes tests hang if unmocked.

Use this skill when

Writing tests for a component that renders kit components, or diagnosing tests that hang or fail on network.

Decide what you are testing

TestingApproach
Your logic — selection, routing, stateUnit test with CometChat mocked
Kit component internalsDon't. It is a third-party dependency with its own tests
Your app's chat flow end-to-endPlaywright against a real dev app, two accounts
Realtime deliveryManual, two browsers. Not automatable cheaply

The common mistake is unit-testing kit internals. Test the seam: given a click, does your component set the right active chat?

Mock CometChat in unit tests

Kit components open sockets and call the API at construction. Left real, tests hang, fail offline, and pollute a live app with test data.

ts
// src/testing/cometchat.mock.ts
export const cometChatUIKitMock = {
  initFromSettings: jest.fn().mockResolvedValue({}),
  login: jest.fn().mockResolvedValue({ getUid: () => 'test-uid' }),
  loginWithAuthToken: jest.fn().mockResolvedValue({ getUid: () => 'test-uid' }),
  logout: jest.fn().mockResolvedValue(undefined),
  getLoggedInUser: jest.fn().mockReturnValue({ getUid: () => 'test-uid' }),
  isInitialized: jest.fn().mockReturnValue(true),
  isCallingEnabled: jest.fn().mockReturnValue(false),
};

Point the module at it (Jest):

ts
jest.mock('@cometchat/chat-uikit-angular', () => ({
  ...jest.requireActual('@cometchat/chat-uikit-angular'),
  CometChatUIKit: cometChatUIKitMock,
}));

Keep requireActual so real component classes and ChatStateService still exist — you want your own wiring exercised, only the network faked.

TestBed with standalone kit components

They are standalone, so they go in imports, exactly as in the app:

ts
import { TestBed } from '@angular/core/testing';
import { ChatComponent } from './chat.component';

beforeEach(async () => {
  await TestBed.configureTestingModule({ imports: [ChatComponent] }).compileComponents();
});

If a test fails with "is not a known element", the component under test is missing it from its own imports — a real bug the test just caught, not a test problem.

Prefer testing ChatStateService over the DOM

Assert state, not kit markup. Kit internals change between releases; your wiring should not.

ts
it('sets the active group when a group conversation is clicked', () => {
  const fixture = TestBed.createComponent(ChatComponent);
  const cmp = fixture.componentInstance;

  // Mock the SHAPE the kit actually emits: a Conversation whose subject is a Group.
  // Handing open() a bare { getGuid } instead lets a duck-typing bug pass the test
  // while every group chat throws "getUid is not a function" in the browser.
  const group = new CometChat.Group('g1', 'Team', CometChat.GROUP_TYPE.PUBLIC);
  const conversation = { getConversationType: () => 'group', getConversationWith: () => group };

  cmp.open(conversation as unknown as CometChat.Conversation);
  expect(cmp.chatState.getActiveGroup()).toBeTruthy();
  expect(cmp.chatState.getActiveUser()).toBeFalsy();      // the group must NOT land in the user slot
});

Mock the emitted shape, not the shape your code happens to check. A mock built backwards from the implementation can only confirm the implementation — including its bugs. (itemClick) emits a Conversation; a test that passes anything else is not exercising the wiring.

E2E with Playwright

Use a real dev app and two seeded users. What is worth asserting:

  • The conversation list renders rows
  • Clicking one opens header + list + composer
  • Sending text makes it appear
  • No console errors — the kit fails quietly, so this catches a lot
  • Nothing collapsed — assert the message list's height is non-zero; a zero-height pane is the most common silent break
ts
const box = await page.locator('cometchat-message-list').boundingBox();
expect(box!.height).toBeGreaterThan(100);

Seed users and conversations through the REST API in setup, not the UI.

Not worth automating

Realtime delivery between two clients, calls (needs media permissions and two peers), and push (needs a real device and a backgrounded app). Verify these manually and say so in the test plan rather than writing brittle automation.

Common pitfalls

  1. Unmocked CometChat in unit tests → hangs, flakes, offline failures.
  2. Mocking the whole module without requireActual → your own wiring never runs.
  3. Asserting kit DOM internals → breaks on every kit release.
  4. Tests against a production app → real users, real data.
  5. No zero-height assertion in E2E → the most common visual break goes unnoticed.
  6. No teardown in tests → leaked listeners bleed across specs.

Verify it works

Unit tests pass offline · no test opens a real socket · a missing imports entry fails a test · E2E asserts non-zero height and no console errors · manual checks are documented, not faked.

Domande frequenti

Cosa fa la skill IA Cometchat Angular V5 Testing?

Test an Angular app that embeds CometChat — what to mock vs exercise for real, TestBed setup for standalone kit components, avoiding real network in unit tests, and a two-account manual pass for realtime. Triggers: 'write tests for my chat', 'mock cometchat in jest', 'testbed cometchat', 'my tests hang', 'e2e test the chat'.

Perché usare Cometchat Angular V5 Testing su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Cometchat Angular V5 Testing è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Cometchat Angular V5 Testing in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/cometchat/cometchat-skills/tree/main/skills/cometchat-angular-v5-testing. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Cometchat Angular V5 Testing?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Cometchat Angular V5 Testing?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Cometchat Angular V5 Testing: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Cometchat Angular V5 Testing è gratuita?

Sì. È pubblicata su GitHub da cometchat con licenza MIT. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇