一键导入
write-tests
Guide for writing comprehensive tests for Ion Design System components using Jest + Angular Testing Library
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Guide for writing comprehensive tests for Ion Design System components using Jest + Angular Testing Library
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Guides creating new components for the Ion Design System. Use this skill whenever the user asks to create, add, or build a new Ion component, new DS component, or new design system component. This skill MUST be used even if the user just says "create a component" or "add a new component" without being explicit — if the context is the Ion repo, always invoke this skill. It enforces that existing Ion components are reused inside new ones instead of native HTML elements.
Guides cherry-picking commits from the main branch (Angular v21) to support/v19 or support/v8 in the Ion Design System. Use this skill whenever the user mentions cherry-pick, backport, porting a fix or feature to v19/v8/support branches, propagating changes between branches, or needs to apply a commit from main to an older branch.
Step-by-step guide to create a new Ion Design System component with all required files
Guide for creating Storybook stories for Ion Design System components
| name | write-tests |
| description | Guide for writing comprehensive tests for Ion Design System components using Jest + Angular Testing Library |
Follow this guide to write comprehensive tests for an existing Ion component.
Determine which component needs tests. Read the component's .component.ts to understand:
input() signals and their types/defaultsoutput() signals.component.html)The test file should be at projects/ion/src/lib/<component>/<component>.component.spec.ts.
@if blocks)Use iteration when testing multiple values of the same input:
const sizes: Array<'sm' | 'md' | 'lg' | 'xl'> = ['sm', 'md', 'lg', 'xl'];
sizes.forEach((size) => {
it(`should render size: ${size}`, () => {
fixture.componentRef.setInput('size', size);
fixture.detectChanges();
const el = fixture.nativeElement.querySelector('button');
expect(el.classList.contains(`ion-btn-${size}`)).toBe(true);
});
});
it('should emit event', () => {
const spy = jest.fn();
component.ionOnClick.subscribe(spy);
fixture.detectChanges();
const el = fixture.nativeElement.querySelector('button');
el.click();
expect(spy).toHaveBeenCalled();
});
fixture.componentRef.setInput() to set signal inputsfixture.detectChanges() after changing inputsfixture.nativeElement.querySelector() for DOM queriesdocument.body.querySelector() for overlay/portal elements (dropdowns, modals, tooltips)[data-testid] attribute selectors for reliable queriesjest.fn() for spy/mock functionsnpx jest --testPathPattern=<component-name>
npx jest --testPathPattern=<component-name> --coverage