Skip to main content
skill CX Codex

experience-lwc-accessibility-jest-run — Claude Code skill

Runs Sa11y accessibility unit tests on LWC components using Bazel or standalone Jest.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add forcedotcom/sf-skills --skill experience-lwc-accessibility-jest-run -a claude-code
Open on GitHub

What experience-lwc-accessibility-jest-run does

The skill selects and shapes test commands for running Sa11y accessibility suites on Lightning Web Components. It checks for a WORKSPACE file to distinguish Salesforce Core builds from standalone projects. For standalone repositories, it generates npm test -- --testMatch="**/*.accessibility.test.js" without injecting SA11Y_* environment variables.

In Core repositories, it formats Bazel targets by stripping .test.js extensions and adding flags like --test_env=SA11Y_AUTO=1. When saving rendered DOM markup, it directs output to sfdc-test/unit/javascript/htdocs/sa11y/jest to prevent EPERM errors. The skill ignores Selenium browser tests, functional Jest tests, and static WCAG audits.

Prerequisites include Node 18.0.0 or higher and npm 8.0 or higher. Standalone setups require @sa11y/jest and a configured jsdom test environment. In Bazel runs, exit code 3 signals failed accessibility tests, while code 1 marks a broken build target or command execution failure.

What it helps with

  • run Sa11y accessibility unit tests for a specific LWC component
  • format Bazel commands for Core accessibility targets without cached results
  • reproduce an A11yBug failure using its exact test path
  • save Sa11y rendered DOM HTML without encountering EPERM permission errors

Example prompts for the agent

  • Run standalone Sa11y accessibility tests for MyComponent.
  • Generate the Bazel command to run MyComponent.accessibility.test.js with fresh results.
  • Execute all accessibility tests in the experience-components module and save rendered HTML.

How to install experience-lwc-accessibility-jest-run

1Skills CLI (Vercel)

npx skills add forcedotcom/sf-skills --skill experience-lwc-accessibility-jest-run -a claude-code

2Manually: put the files in place

~/.claude/skills/experience-lwc-accessibility-jest-run/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/experience-lwc-accessibility-jest-run/

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

Questions about experience-lwc-accessibility-jest-run

How do I install experience-lwc-accessibility-jest-run in Claude Code?

Run npx skills add forcedotcom/sf-skills --skill experience-lwc-accessibility-jest-run -a claude-code.

What environments does this skill support?

It supports Salesforce Core environments running Bazel and standalone Jest setups with @sa11y/jest in jsdom.

What do the Bazel test exit codes indicate?

Exit code 0 confirms all tests passed. Exit code 3 indicates test failures, while code 1 means the Bazel build or command failed.

Source text

SKILL.md · Apache-2.0
---
name: experience-lwc-accessibility-jest-run
description: "Use ALWAYS when running Sa11y accessibility Jest tests for an LWC — locally before pushing, producing the command(s), running one file vs a suite, selecting tests by naming convention, saving Sa11y-rendered HTML, or reproducing a Sa11y/A11yBug failure. Covers core (Bazel; `bazel test //<module>:<target>`) and standalone `npx jest` (`.accessibility.test.js`, `@sa11y/jest`). REQUIRED for a `run-plan.md`, a failing a11y test's exit code, or `SA11Y_*`/`A11yBug`/core-Bazel test paths. DO NOT TRIGGER for functional Jest tests, a11y review without running tests (use experience-accessibility-validate), or Selenium-based a11y tests."
metadata:
  version: "1.0"
  domains: ["Experience"]
  relatedSkills:
    - "experience-accessibility-validate"
  cliTools:
    - tool: ["node"]
      semver: ">=18.0.0"
    - tool: ["npm"]
      semver: ">=8.0"
---
<!-- a11y-expert-managed-skill -->

# Running LWC Accessibility Jest Tests

Run Sa11y accessibility unit tests on Lightning Web Components in either:

- **Core (Bazel)** — when a `WORKSPACE` file is present.
- **Standalone (Jest)** — when there's no `WORKSPACE`.

Selenium-level reproductions, GUS A11yBug ingestion, and other internal
Salesforce-only flows are out of scope for this skill. For source-code-level
WCAG review without running tests, see `experience-accessibility-validate`.

## When to Use This Skill

- User wants to run accessibility unit tests (Sa11y Jest) locally before
  pushing a fix.
- User has a known failing test file path (e.g. from an A11yBug's
  `Test_Names__c`) and wants to target it directly.
- User is iterating on an accessibility fix and needs the fastest
  pass/fail signal.

## Prerequisites

- For Bazel Jest tests: a Salesforce core build environment (a `WORKSPACE`
  file is present).
- For standalone Jest tests: `@sa11y/jest` installed and configured.


## Workflow

Choose the approach based on the environment. If this is not a Salesforce core
build environment, do not mention the Core workflow.

### Core (Bazel)

Use this mode when a `WORKSPACE` file is present. The base command is:

```bash
{coreRootPath}/tools/bazel test [TARGET] --test_output=streamed --test_env=SA11Y_AUTO=1 --test_env=SA11Y_ENABLE_DOM_MUTATION_OBSERVER=1
```

Replace `{coreRootPath}` with the Core repository root, `{moduleName}` with the
module name, and `{relativePath}` with the test file path without the `.test.js`
extension.

To discover targets and paths:

```bash
find {coreRootPath}/{moduleName} -name "*.test.js" -type f
{coreRootPath}/tools/bazel query "tests(//{moduleName}:*)"
```

Component tests typically live under
`modules/{componentDir}/{componentName}/__tests__/`.

Prefer a single-file target when the failing test path is known:

```bash
{coreRootPath}/tools/bazel test //{moduleName}:{relativePath} --test_output=streamed --test_env=SA11Y_AUTO=1 --test_env=SA11Y_ENABLE_DOM_MUTATION_OBSERVER=1
```

Run all Sa11y Jest tests in a module when a specific test is not known:

```bash
{coreRootPath}/tools/bazel test //{moduleName}:sa11y_jest_test --test_output=streamed --test_env=SA11Y_AUTO=1 --test_env=SA11Y_ENABLE_DOM_MUTATION_OBSERVER=1
```

Multiple module targets can be passed to the same command. To filter tests
within a module, add `--test_arg=--testMatch="**/{modulePath}/**"`.

Useful options:

- Update snapshots: `--test_arg="--updateSnapshot"`
- Disable cached test results: `--cache_test_results=no`
- Save rendered HTML:
  `--test_env=SA11Y_ENABLE_RENDERED_DOM_SAVE=1 --test_env=SA11Y_RENDERED_DOM_SAVE_PATH=sfdc-test/unit/javascript/htdocs/sa11y/jest`

Use `sfdc-test/unit/javascript/htdocs/sa11y/jest` as the rendered DOM save path
to avoid EPERM errors.

### Standalone (Jest)

Use this mode when no `WORKSPACE` file is present. Run all accessibility tests:

Do **not** prepend `SA11Y_*` environment variables in standalone mode;
`@sa11y/jest` is activated through the project's Jest setup.

```bash
npm test -- --testMatch="**/*.accessibility.test.js"
```

Or target a specific file:

```bash
npm test -- src/components/MyComponent/__tests__/MyComponent.accessibility.test.js
```

Use the filename or path supplied by the user. When the named test is in the
current directory, keep a bare filename bare instead of inventing a path.

Other useful options are `--coverage`, `--updateSnapshot`, `--watch`, and
`--verbose`. To target a named test, use
`npm test -- --testNamePattern="MyComponent accessibility"`.

Ensure Jest uses a `jsdom` environment and loads the project's `@sa11y/jest`
setup file. Copy or adapt the bundled `assets/jest.config.js` template into
the project's Jest configuration, and copy `assets/sa11y-jest-setup.js` to
`test/setup/sa11y-setup.js`. If the project already has a Jest configuration,
merge the relevant settings instead of overwriting unrelated configuration.

The `SA11Y_*` variables shown above are for Core/Bazel only; the Bazel commands
already include them.

## Response Scope

Answer only what the user asked. Emit the requested command or commands plus
the relevant exit-code meaning. Do not add watch, coverage, snapshot-update,
HTML-save, or other variants unless the user requests them.

## Expected Exit Codes

- Bazel: `0` means all tests passed, `3` means tests failed, and `1` means the
  build or command failed.
- Jest: `0` means all tests passed and `1` means tests failed or an error
  occurred.


## Verification Checklist

- [ ] Sa11y Jest run completed with a clear pass/fail signal (exit 0 or 3
      for Bazel; exit 0 or 1 for Jest).
- [ ] If snapshots were intentionally updated, the new snapshots are
      committed alongside the fix.


## Troubleshooting

- **Bazel test "not found"** — the target path is off. Remember to drop the
  `.test.js` extension in `{relativePath}`.
- **HTML saving fails with EPERM** — use the prescribed save path
  `sfdc-test/unit/javascript/htdocs/sa11y/jest`.
- **Standalone tests do not run** — verify the test naming pattern, Jest
  configuration, `@sa11y/jest` dependency, and `jsdom` environment.

© forcedotcom · Apache-2.0 · forcedotcom/sf-skills

Similar skills

Everything for Testing and QA →

From the same set167

service-itsm-agentic-setup-incident-sla-configure Sets up end-to-end Incident SLA pipelines in Salesforce Service Cloud ITSM via the headless-360 MCP server. Configures policies, milestones, and entitlements. CX Codex +1 1,200installs service-concierge-portal-generate Deploys an Agentforce Concierge portal on an LWR Experience Cloud site: provisions the site, configures components and branding, wires the agent, enables guest access and publishes. CX Codex +1 1,200installs service-agentforce-channel-configure This skill wires an existing Agentforce agent to a channel: it resolves a fallback queue, sets up inbound routing, and can add outbound escalation. CX Codex +1 1,200installs dx-org-shape-manage Manages Salesforce org shape lifecycles using the sf CLI to capture, inspect, and delete baseline org configurations without copying data. CX Codex +1 1,000installs experience-accessibility-validate Reviews a Lightning Web Component's HTML, JS and CSS against WCAG 2.2 and writes a report citing the specific success criteria. CX Codex +1 857installs dx-devops-conflict-resolve Diagnoses and clears what blocks a DevOps Center promotion: Git merge conflicts in metadata and deploy failures. Useful before you promote. CX Codex +1 824installs dx-devops-request-status Polls the status of asynchronous Salesforce DevOps Center promotion or deploy requests. It tracks operation progress using the request token. CX Codex +1 779installs experience-cms-content-generate Creates, edits and publishes Salesforce CMS records from a text prompt, one at a time or in bulk. Useful when content gets written straight from the agent. CX Codex +1 765installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor