Skip to main content
skill CX Codex

jasmine-skill — Claude Code skill: generate Jasmine tests

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.

MIT 237 installs ★ 393 updated 2026-10-13

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add LambdaTest/agent-skills --skill jasmine-skill -a claude-code
Open on GitHub

What jasmine-skill 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.

What it helps with

  • 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 for the agent

  • 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

How to install jasmine-skill

1Skills CLI (Vercel)

npx skills add LambdaTest/agent-skills --skill jasmine-skill -a claude-code

2Manually: put the files in place

~/.claude/skills/jasmine-skill/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/jasmine-skill/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about jasmine-skill

How do I install jasmine-skill for Claude Code?

Run npx skills add LambdaTest/agent-skills --skill jasmine-skill -a claude-code, then check ~/.claude/skills/jasmine-skill/SKILL.md.

What does jasmine-skill do?

It generates BDD test specs: describe blocks, it tests, matchers for assertions, spies for mocking, and async patterns with async/await or done callbacks.

Which platforms support jasmine-skill?

Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, and OpenCode each have their own install command.

Source text

SKILL.md · MIT
---
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 |
| §2 Spies — Complete API | spyOn, createSpyObj, callFake, returnValues, call tracking |
| §3 Async Testing | async/await, expectAsync, promise matchers |
| §4 Custom Matchers | Domain-specific matchers, asymmetric matchers |
| §5 Test Organization | Nested describe, shared state, focused/excluded |
| §6 Fetch & Module Mocking | globalThis.fetch spy, HTTP error handling |
| §7 Browser Testing | DOM creation, keyboard events, focus trapping with Karma |
| §8 CI/CD Integration | GitHub Actions with coverage, browser testing |
| §9 Debugging Table | 12 common problems with causes and fixes |
| §10 Best Practices | 14-item checklist for production Jasmine testing |

© TestMu AI · MIT · LambdaTest/agent-skills

Similar skills

All skills for Testing and QA →

From the same set47

The whole set →
testng-skill Generates Java TestNG tests with groups, data providers, parallel execution, suite XML, and listeners. Use it when building or organising TestNG coverage. CX Codex +1 243installs codeception-skill Generates PHP Codeception acceptance, functional, and unit tests using BDD actor workflows. Useful for web interface validation and browser automation. CX Codex +1 243installs flutter-testing-skill flutter-testing-skill generates widget tests, integration tests, and golden tests for Flutter in Dart. Runs locally or on real devices via TestMu AI cloud. CX Codex +1 242installs smartui-skill This skill prepares SmartUI visual regression tests for screenshot comparison. Use it to check pages and components across browsers and viewports. CX Codex +1 237installs mocha-skill Creates Mocha tests for JavaScript and TypeScript with Chai assertions and Sinon mocks. Useful when a project needs unit-test scaffolding. CX Codex +1 235installs unittest-skill Generates Python unittest tests with TestCase, setUp/tearDown, and assertion methods. Triggers when you mention unittest, TestCase, or self.assertEqual. CX Codex +1 235installs espresso-skill Generate Espresso UI tests for Android apps written in Kotlin or Java. Use the skill to exercise screen interactions and check what the interface displays afterward. CX Codex +1 234installs laravel-dusk-skill Generates E2E tests with Laravel Dusk. The agent writes PHP code with $browser->visit, form checks, and Page Objects. CX Codex +1 231installs

Project sponsors

Companies that keep this analytics open