Jasmine Testing Skill
BDD testing framework that scales with your JavaScript applications
❌ Writing comprehensive unit tests in JavaScript is time-consuming and error-prone without a structured BDD framework.
✅ Generate well-organized Jasmine test suites with proper assertions, spies, and async support in minutes.
- ✓BDD-style describe and it syntax for readable tests
- ✓Built-in spies for mocking and tracking function calls
- ✓Comprehensive matchers for assertions and error handling
- ✓Native async and Promise support for modern code
👁 2 views · 📦 0 installs
Free to install — no account needed
Copy the command below and paste into your agent.
Instant access • No coding needed • No account needed
What you get in 5 minutes
- Full skill code ready to install
- Works with 4 AI agents
- Lifetime updates included
Run this helper
Answer a few questions and let this helper do the work.
▸Advanced: use with your AI agent
Description
--- 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 |
Security Status
Scanned
Passed automated security checks
Related AI Tools
More Career Boost tools you might like
ru-text — Russian Text Quality
FreeApplies professional Russian typography, grammar, and style rules to improve text quality across content types
/forge:工作流总入口
Free'Forge 工作流总入口。检查项目状态,推荐下一步该用哪个 skill。任何时候不知道下一步该干什么,就用 /forge。触发方式:用户说"forge"、"下一步"、"接下来做什么"、"继续"(在没有明确上下文时)。'
TypeScript React & Next.js Production Patterns
FreeProduction-grade TypeScript reference for React & Next.js covering type safety, component patterns, API validation, state management, and debugging
Charles Proxy Session Extractor
FreeExtracts HTTP/HTTPS request and response data from Charles Proxy session files (.chlsj format), including URLs, methods, status codes, headers, request bodies, and response bodies. Use when analyzing captured network traffic from Charles Proxy debug
Java Backend Interview Simulator
FreeSimulates realistic Java backend technical interviews with customizable interviewer styles and candidate levels for Chinese tech companies
AI News & Trends Intelligence
FreeFetches latest AI/ML news, trending open-source projects, and social media discussions from 75+ curated sources for comprehensive AI briefings