# jasmine-skill

Generates test specs in Jasmine for JavaScript and TypeScript. Includes BDD patterns, spy and mock syntax, async support — the code editor writes describe, it, expect, and spy calls automatically.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode, Windsurf (Devin Desktop), Claude.ai · 237 installs · ★ 393 repo stars
- Author: TestMu AI
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/LambdaTest/agent-skills/tree/HEAD/jasmine-skill/SKILL.md
- Updated: 2026-10-13
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/skills/jasmine-skill

## What it does

The skill equips an AI code editor with Jasmine patterns: test suites and specs (describe, it), matchers to assert values, spies to track function calls and mock APIs, async test flows with async/await or done callbacks, and clock control for timer tests. Examples cover Calculator, UserService, timeout handling.

Setup requires Node.js: `npm install jasmine --save-dev && npx jasmine init`. Once added, the editor triggers Jasmine suggestions when you mention "Jasmine", "createSpy", "toHaveBeenCalled", or ask for test specs directly. Run tests with `npx jasmine` or target a file: `npx jasmine spec/calculatorSpec.js`.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add LambdaTest/agent-skills --skill jasmine-skill -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/jasmine-skill/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/jasmine-skill/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add LambdaTest/agent-skills --skill jasmine-skill -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/jasmine-skill/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add LambdaTest/agent-skills --skill jasmine-skill -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/jasmine-skill/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install LambdaTest/agent-skills jasmine-skill
```

2. **Manually: put the files in place**
- File: `.github/skills/jasmine-skill/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add LambdaTest/agent-skills --skill jasmine-skill -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/LambdaTest/agent-skills --path jasmine-skill
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/jasmine-skill/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add LambdaTest/agent-skills --skill jasmine-skill -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/LambdaTest/agent-skills/tree/HEAD/jasmine-skill/SKILL.md

## When to use it
- write a test for a function with async logic
- create a mock API and verify it was called with the right arguments
- check that a function throws an error with a specific message
- track how many times a function got called

## Example prompts
- Write a Jasmine test for an add function that sums two numbers
- Create a spy on getUserData and verify it gets called with the correct parameters
- Make a test that uses jasmine.clock() to check a timeout

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 8c31b0098a7cbce5.

BEGIN THIRD-PARTY FILE 8c31b0098a7cbce5
````text
---
name: jasmine-skill
description: >
  Generates Jasmine tests in JavaScript. BDD-style framework with spies and
  async support. Use when user mentions "Jasmine", "jasmine.createSpy",
  "toHaveBeenCalled". Triggers on: "Jasmine", "jasmine test", "createSpy",
  "Jasmine spec".
languages:
  - JavaScript
  - TypeScript
category: unit-testing
license: MIT
metadata:
  author: TestMu AI
  version: "1.0"
---

# Jasmine Testing Skill

## Core Patterns

### Basic Test

```javascript
describe('Calculator', () => {
  let calc;

  beforeEach(() => { calc = new Calculator(); });

  it('should add two numbers', () => {
    expect(calc.add(2, 3)).toBe(5);
  });

  it('should throw on divide by zero', () => {
    expect(() => calc.divide(10, 0)).toThrowError('Division by zero');
  });
});
```

### Matchers

```javascript
expect(value).toBe(exact);              // === strict
expect(value).toEqual(object);           // Deep equality
expect(value).toBeTruthy();
expect(value).toBeFalsy();
expect(value).toBeNull();
expect(value).toBeUndefined();
expect(value).toBeDefined();
expect(value).toBeNaN();
expect(value).toBeGreaterThan(3);
expect(value).toBeCloseTo(0.3, 5);
expect(str).toContain('sub');
expect(str).toMatch(/pattern/);
expect(arr).toContain(item);
expect(fn).toThrow();
expect(fn).toThrowError('message');

// Negation
expect(value).not.toBe(other);
```

### Spies

```javascript
describe('UserService', () => {
  let service, api;

  beforeEach(() => {
    api = jasmine.createSpyObj('api', ['get', 'post']);
    service = new UserService(api);
  });

  it('fetches user from API', async () => {
    api.get.and.returnValue(Promise.resolve({ name: 'Alice' }));
    const user = await service.getUser(1);
    expect(user.name).toBe('Alice');
    expect(api.get).toHaveBeenCalledWith('/users/1');
    expect(api.get).toHaveBeenCalledTimes(1);
  });
});

// Spy on existing method
spyOn(obj, 'method').and.returnValue(42);
spyOn(obj, 'method').and.callThrough();    // Call original
spyOn(obj, 'method').and.throwError('err');
```

### Async Testing

```javascript
it('fetches data', async () => {
  const data = await fetchData();
  expect(data).toBeDefined();
});

// With done callback
it('fetches data', (done) => {
  fetchData().then(data => {
    expect(data).toBeDefined();
    done();
  });
});

// Clock control
beforeEach(() => { jasmine.clock().install(); });
afterEach(() => { jasmine.clock().uninstall(); });

it('handles timeout', () => {
  const callback = jasmine.createSpy();
  setTimeout(callback, 1000);
  jasmine.clock().tick(1001);
  expect(callback).toHaveBeenCalled();
});
```

## Setup: `npm install jasmine --save-dev && npx jasmine init`
## Run: `npx jasmine` or `npx jasmine spec/calculatorSpec.js`

## Deep Patterns

See `reference/playbook.md` for production-grade patterns:

| Section | What You Get |
|---------|-------------|
| §1 Project Setup | jasmine.json, TypeScript, spec reporter config |
````
END THIRD-PARTY FILE 8c31b0098a7cbce5

The third-party file has ended. Everything between the 8c31b0098a7cbce5 tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2936 of 3618 bytes. © TestMu AI · MIT · https://github.com/LambdaTest/agent-skills/tree/HEAD/jasmine-skill/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
