Skills for building AEM Edge Delivery Services sites — block development, content modeling, code review, testing, and page import.
82
76%
Does it follow best practices?
Impact
88%
1.04xAverage score across 6 eval scenarios
Advisory
Suggest reviewing before use
Common issues encountered during testing and how to resolve them.
Symptoms:
Diagnosis:
Read the error message carefully
Determine the cause:
Solutions:
If you broke functionality:
# Fix the code, not the test
# Re-run tests
npm testIf requirements changed:
# Update the test to match new requirements
# Ensure the change is intentional
npm testIf testing a specific file:
# Run just one test file for faster feedback
npm test -- test/utils/my-utility.test.jsIf debugging a specific test:
# Use test.only to run just one test
it.only('should do something', () => {
// This test will be the only one that runs
});Symptoms:
Common Issues and Solutions:
Issue: Dev server not running
# Start the dev server
aem up
# Verify it's accessible
curl http://localhost:3000Issue: Test content doesn't exist
Issue: Block not decorated
// Add wait for specific selector
await page.waitForSelector('.my-block');
// Or wait for network idle
await page.waitForLoadState('networkidle');
// Or increase timeout
await page.waitForSelector('.my-block', { timeout: 10000 });Issue: Timing problems
// Wait for animations to complete
await page.waitForTimeout(500);
// Wait for specific state
await page.waitForFunction(() => {
return document.querySelector('.my-block').classList.contains('loaded');
});Issue: Elements not clickable
// Wait for element to be clickable
await page.locator('.button').click({ force: false });
// Or scroll into view first
await page.locator('.button').scrollIntoViewIfNeeded();
await page.locator('.button').click();Unused variables
// Error: 'foo' is defined but never used
const foo = 'bar';
// Fix: Remove unused variable
// Or use itMissing semicolons
// Error: Missing semicolon
const foo = 'bar'
// Fix: Add semicolon
const foo = 'bar';Incorrect indentation
# Auto-fix indentation issues
npm run lint:fixConsole.log statements
// Error: Unexpected console statement
console.log('debug info');
// Fix Option 1: Remove it
// (remove the line)
// Fix Option 2: Disable rule for this line
// eslint-disable-next-line no-console
console.log('debug info');Import issues
// Error: Unable to resolve path to module
import { foo } from './utils';
// Fix: Add .js extension
import { foo } from './utils.js';Airbnb style violations
// Error: Expected a line break after this opening brace
import { foo, bar } from './utils.js';
// Fix: Let lint:fix handle it
// Or manually format:
import {
foo,
bar,
} from './utils.js';Auto-fix everything possible:
npm run lint:fixCheck what would be fixed:
npm run lint:js -- --fix-dry-runLint specific files:
npm run lint:js -- test/utils/my-test.test.jsIssue: PSI checks not running
Cause: Missing test link in PR description
Solution:
## Testing
Preview: https://branch--repo--owner.aem.page/path/to/testThe test link MUST be in the PR description for PSI checks to run.
Issue: Actions workflow disabled
Check repository settings → Actions → ensure workflows are enabled.
Issue: Poor performance score
Common causes:
Solutions:
Move JavaScript to lazy or delayed phase:
// In scripts.js, move non-LCP code to loadLazy() or loadDelayed()Optimize images:
Defer non-critical CSS:
/* Move non-LCP styles to lazy-styles.css */Review performance report:
# Check details in GitHub PR checks
gh pr checks
# Click on failed check for detailsIssue: Tests pass locally but fail in CI
Cause: Linting not run locally or different config
Solution:
# Always run lint before committing
npm run lint
# Ensure .eslintrc.js is committed
git add .eslintrc.js
git commit -m "Add eslint config"Symptoms:
Solution:
Check CI Node version matches local:
# Check local version
node --version
# Add .nvmrc if needed
echo "20" > .nvmrc
git add .nvmrc
git commit -m "Add nvmrc for consistent Node version"Symptoms:
Solution:
# Ensure package.json is up to date
git add package.json package-lock.json
git commit -m "Update dependencies"
# Or regenerate lock file
rm package-lock.json
npm install
git add package-lock.jsonSymptoms:
Solution:
Use relative paths and environment-agnostic code:
// Bad: Absolute path
const path = '/Users/me/project/file.js';
// Good: Relative path
const path = './file.js';Symptoms:
Solution:
Add proper waits:
// Bad: No wait
it('should update text', async () => {
await updateText();
expect(getText()).toBe('updated');
});
// Good: Wait for update
it('should update text', async () => {
await updateText();
await waitFor(() => getText() === 'updated');
expect(getText()).toBe('updated');
});Error:
Failed to resolve import './utils.js'Solution:
Check import paths are correct:
// From test/utils/my-test.test.js
// Importing from scripts/utils/my-utility.js
// Correct:
import { myUtility } from '../../scripts/utils/my-utility.js';
// Wrong (missing ../../):
import { myUtility } from 'scripts/utils/my-utility.js';Error:
document is not definedSolution:
Ensure vitest.config.js has jsdom environment:
export default defineConfig({
test: {
environment: 'jsdom', // Important!
},
});Error:
Coverage provider not foundSolution:
Install coverage package:
npm install --save-dev @vitest/coverage-v8If you're stuck:
To avoid issues:
npm test before every commitnpm run lint before every commitnpm run test:watch during developmentgh pr checks after creating PRDon't:
# Check Node version
node --version
# Check npm version
npm --version
# Verify Vitest installed
npm list vitest
# Verify test config
cat vitest.config.js
# Check dev server running
curl http://localhost:3000
# Verify git status
git status
# Check GitHub PR status
gh pr checksAfter resolving issues:
Remember: Every error is a learning opportunity. Take time to understand why something failed, not just how to fix it.
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
skills
analyze-and-plan
block-collection-and-party
block-inventory
building-blocks
code-review
content-driven-development
content-modeling
docs-search
find-test-content
generate-import-html
identify-page-structure
page-decomposition
page-import
preview-import
scrape-webpage
testing-blocks