Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

Testing Blocks

БесплатноБез исполняемых скриптовНе проверен

Guide for testing code changes in AEM Edge Delivery projects including blocks, scripts, and styles. Use this skill after making code changes and before…

adobeот adobe★ 45 звёзд на GitHub23 установки в других каталогах

Об этом скилле

Testing Blocks

This skill guides you through testing code changes in AEM Edge Delivery Services projects. Testing follows a value-versus-cost philosophy: create and maintain tests when the value they bring exceeds the cost of creation and maintenance.

Related Skills

  • content-driven-development: Test content created during CDD serves as the basis for testing
  • building-blocks: This skill is automatically invoked after block implementation
  • block-collection-and-party: May provide reference test patterns from similar blocks

When to Use This Skill

Use this skill:

  • ✅ After implementing or modifying blocks
  • ✅ After changes to core scripts (scripts.js, delayed.js, aem.js)
  • ✅ After style changes (styles.css, lazy-styles.css)
  • ✅ After configuration changes that affect functionality
  • ✅ Before opening any pull request with code changes

This skill should be automatically invoked by the building-blocks skill after implementation is complete.

Testing Philosophy: Value vs Cost

The Principle: Create and maintain tests when the value they bring exceeds the cost of creation and maintenance.

Keeper Tests (High Value, Worth Maintaining)

✅ Write unit tests for:

  • Logic-heavy utility functions used across multiple blocks
  • Data processing and transformation logic
  • API integrations and external service interactions
  • Complex algorithms or business logic
  • Shared libraries and helper functions

These tests provide lasting value because they catch regressions in reused code, serve as living documentation, and are fast and easy to maintain.

Throwaway Tests (Lower Value, Use Once)

⚠️ Use browser tests for:

  • Block decoration logic (DOM transformations)
  • Specific DOM structures or UI layouts
  • Visual appearance validation
  • Block-specific rendering behavior

These tests are better done in a browser because DOM structures change frequently, visual validation requires human judgment, and maintaining UI tests is expensive relative to their value.

Important: Even throwaway tests have value! Use them to:

  1. Validate your implementation works correctly
  2. Take screenshots to evaluate visual correctness
  3. Show screenshots to humans for feedback
  4. Include screenshots in PRs to aid review

Organization: Keep throwaway tests in test/tmp/ and test content in drafts/tmp/. Both directories should be gitignored so temporary test artifacts aren't committed.

Testing Checklist

Before opening a pull request, complete ALL of the following:

  • Existing tests pass - All keeper tests still pass with your changes
  • Unit tests written - New keeper tests for any logic-heavy utilities or data processing
  • Browser validation - Feature tested in local dev server, screenshots captured
  • All variants tested - Each variant/configuration of blocks validated
  • Responsive behavior - Tested on mobile, tablet, desktop viewports
  • Linting passes - npm run lint completes without errors
  • Branch pushed - Code committed and pushed to feature branch
  • GitHub checks verified - Use gh checks to confirm all CI checks pass

Testing Methods Overview

1. Unit Tests (KEEPER TESTS)

When to use: Logic-heavy functions, utilities, data processing, API integrations

Quick start:

# Verify test setup (see resources/vitest-setup.md if not configured)
npm test

# Write test for utility function
# test/utils/my-utility.test.js
import { describe, it, expect } from 'vitest';
import { myUtility } from '../../scripts/utils/my-utility.js';

describe('myUtility', () => {
  it('should transform input correctly', () => {
    expect(myUtility('input')).toBe('OUTPUT');
  });
});

# Run tests during development
npm run test:watch

Detailed guide: See resources/unit-testing.md

2. Browser Testing (THROWAWAY TESTS)

When to use: Block decoration, visual validation, DOM structure, responsive design

Organization:

  • Test scripts: test/tmp/test-{block}-browser.js
  • Test content: drafts/tmp/{block}.html
  • Screenshots: test/tmp/screenshots/
  • Both test/tmp/ and drafts/tmp/ should be gitignored

Quick start:

# Install Playwright
npm install --save-dev playwright
npx playwright install chromium

# Create test content
# drafts/tmp/my-block.html (copy head.html content, add test markup)

# Start dev server with drafts folder
aem up --html-folder drafts

# Create throwaway test script in test/tmp/
# test/tmp/test-my-block.js
import { chromium } from 'playwright';
import { mkdir } from 'fs/promises';

async function test() {
  await mkdir('./test/tmp/screenshots', { recursive: true });
  const browser = await chromium.launch({ headless: false });
  const page = await browser.newPage();

  await page.goto('http://localhost:3000/drafts/tmp/my-block');
  await page.waitForSelector('.my-block');
  await page.screenshot({ 
    path: './test/tmp/screenshots/my-block.png',
    fullPage: true 
  });
Полный SKILL.md на GitHub

Установить Testing Blocks в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

resources/browser-testing.mdresources/testing-workflow.mdresources/troubleshooting.mdresources/unit-testing.mdresources/vitest-setup.md

FAQ

Что делает скилл Testing Blocks?

Guide for testing code changes in AEM Edge Delivery projects including blocks, scripts, and styles. Use this skill after making code changes and before opening a pull request to validate functionality. Covers unit testing for utilities and logic, browser testing with Playwright/Puppeteer, linting, performance validation, and guidance on which tests to maintain vs use as throwaway validation.

Как установить скилл Testing Blocks?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл Testing Blocks запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить Testing Blocks с