Experience Lwc Accessibility Jest Run

forcedotcom/sf-skills/skills/experience-lwc-accessibility-jest-run

作者 forcedotcome5164d94d751無授權條款1K 個星標收錄於 2026年10月8日更新於 2026年10月8日儲存庫昨天更新

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.

AI 產生的概覽

透過 Bazel 或獨立 Jest 為 Lightning Web Components 執行 Sa11y 無障礙 Jest 測試。

功能
此技能會引導代理對 Lightning Web Components 執行 Sa11y 無障礙單元測試,並依據是否存在 WORKSPACE 檔案,在 Core Bazel 工作流程與獨立 Jest 工作流程之間選擇。它會產生確切的測試指令、說明退出碼意義,並涵蓋要針對單一測試檔案還是整個測試套件、依命名慣例篩選測試、更新快照,以及儲存 Sa11y 算繪的 HTML。它也隨附可調整後放入專案的 Jest 設定與 Sa11y 設定範本。
適用情境
當你需要在推送修正前於本機執行無障礙單元測試、已有已知失敗的測試路徑要直接鎖定,或正在反覆調整無障礙修正並需要快速的通過/失敗訊號時使用。它不適用於功能性 Jest 測試、不執行測試的原始碼層級無障礙審查,或採用 Selenium 的無障礙測試。
執行需求
需要 Node.js 18 或更新版本,以及 npm 8 或更新版本。Core 模式需要具備 WORKSPACE 檔案的 Salesforce core 建置環境與 Bazel;獨立模式需要安裝並設定 @sa11y/jest,並使用 jsdom Jest 環境。它隨附兩個可執行指令碼資源:Jest 設定範本與 Sa11y Jest 設定檔,需複製或合併至專案中。
<!-- 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/sf-skills位於skills/experience-lwc-accessibility-jest-run提交e5164d9

授權條款: 無授權條款

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架

更多來自 forcedotcom/sf-skills 的技能

Service Itsm Teams Itservice Configure

forcedotcom

Configure the "Set Up Salesforce IT Service" checklist for Microsoft Teams Employee Service (ITSM) — the employee side, covering app enablement, marketplace install guidance, user access assignment, and Digital Experience Site selection. Use this for: 'turn on Salesforce IT Service', 'set up IT Service on Teams', 'assign Teams for Employee permission set', 'give employees access to Teams for Employee Service', 'manage user access for Teams ITSM', 'grant users the permission sets needed for Teams Employee Service', 'select a digital experience site for Teams', 'install Salesforce IT Service app on Teams', or any request to complete the IT Service half of the Teams ITSM Go page checklist (including the Manage User Access step). DO NOT TRIGGER for the base Teams Salesforce Go page toggle or Azure/Entra app setup (service-itsm-teams-configure) or for the IT Desk/fulfiller half of the checklist (service-itsm-teams-itdesk-configure).

待分類1K昨天更新

Service Itsm Teams Coordinate

forcedotcom

End-to-end autopilot orchestrator for setting up Microsoft Teams integration in Salesforce Service Cloud ITSM — runs the whole flow (enable the Teams for Employee Service Go feature, register the Microsoft Entra app, populate Named Credentials, configure the IT Desk and IT Service checklists, turn on Swarming, and optionally embed the Agentforce agent) in one continuous pass, stopping only at the points a human must act. Use when the user asks to set up Microsoft Teams for ITSM end to end, 'set up teams for it service', 'do the whole teams itsm setup', 'configure microsoft teams for employee service', or wants a guided Teams ITSM walkthrough. Delegates each stage to a specialized child skill while driving the sequence itself. DO NOT TRIGGER when the user asks to enable Teams alone, configure just the IT Desk or IT Service checklist alone, or enable Swarming alone — delegate directly to the specific child skill in those cases.

待分類1K昨天更新

Service Itsm Teams Itdesk Configure

forcedotcom

Configure the "Set Up Salesforce IT Desk" checklist for Microsoft Teams Employee Service (ITSM) — the fulfiller/agent side, covering app enablement, marketplace install guidance, user access assignment, and Swarming collaboration-tool setup. Use this for: 'turn on Salesforce IT Desk', 'set up IT Desk on Teams', 'assign Teams for IT Desk permission set', 'set Teams as collaboration tool for swarming', 'install Salesforce IT Desk app on Teams', or any request to complete the IT Desk half of the Teams ITSM Go page checklist. DO NOT TRIGGER for the base Teams Salesforce Go page toggle or Azure/Entra app setup (service-itsm-teams-configure) or for the IT Service/employee half of the checklist (service-itsm-teams-itservice-configure).

待分類1K昨天更新

Service Itsm Teams Debug

forcedotcom

透過對 Salesforce 組織執行通過/失敗設定檢查清單,診斷 Microsoft Teams 員工服務(ITSM)設定失敗問題。

DevOps & Cloud1K昨天更新

Service Itsm Teams Employee Agent Configure

forcedotcom

Configure the embedded Agentforce Employee Agent so it replies inside the Microsoft Teams ITSM custom client ('Salesforce Employee Assist' / 'Ask AI Agent'). Use this for: 'set up employee agent in Teams', 'embed Agentforce agent in Teams', 'make the IT Service Employee Agent reply in Teams', 'Teams Ask AI Agent not responding', 'agent joins then leaves without replying', 'configure MIAW deployment for Teams employee agent', 'Teams embedded messaging agent setup'. Builds the whole stack headlessly (zero Setup-UI clicks): the Web messaging channel with User Verification ON, the Enhanced Chat User Verification Key Set (JWKS_URL) it requires, the Teams_AgentForce custom-client deployment, the routing flow to the agent, and the Agent Access permission set that lets the portal user reach the agent. DO NOT TRIGGER for enabling the Teams feature Salesforce Go page toggle (service-itsm-teams-configure) or for configuring notification preferences.

待分類1K昨天更新

Service Itsm Swarming Configure

forcedotcom

透過 Connect API 呼叫啟用 Salesforce Swarming ITSM 功能,並將協作工具設為 Teams。

DevOps & Cloud1K昨天更新