Testing, gate, and CI
How CheckR is verified without an org, how the gate and CI run the same checks, and which tool versions they depend on. The test tiers and what each covers are in architecture: test tiers. Real-org checks are in org evidence.
No-org suite: npm test
npm test runs these in order and stops at the first failure:
npm run lint: ESLint on Aura and LWC JavaScript, thenslds-linteron LWC HTML and CSS.npm run prettier:verify: Prettier on Markdown, JSON, YAML, XML, and the LWC and page formats. Apex is skipped.npm run format:apex:verify: afmt check for Apex, configured by.afmt.toml.npm run test:unitandnpm run test:unit:inband: LWC Jest, in parallel and in band.npm run lint:md: markdownlint-cli2 over all Markdown.npm run test:org-harness,test:reporting,test:object-model,test:docs-images,test:system-mode,test:permission-sets,test:aura-dtos, andtest:release: Node tests for the evidence harness, reporting metadata, the object-model doc, the admin-guide images, the system-mode sites table indocs/architecture.md, permission set class access, Aura request DTO properties, and the public-tree release check.npm run test:analyzerchecks analyzer command construction, optional plugin discovery, exit status, and engine errors using a stubbedsf.
scripts/gate.mjs also warns, without failing, when
sfdx-source/checkr/main/default exists. That folder is ignored retrieve
output; delete it so it is not deployed with the package.
Notes:
- afmt owns Apex (
*.cls,*.trigger,*.apex,*.apexc)..prettierignoreskips those files, and it also keepsdocs/evidence/**verbatim. - afmt 1.0.0 must be on
PATH. CI installs it from the upstream release tarball. npm testneeds no org, no DevHub secrets, and no AER. Apex runs in a separate step.
Static analysis with npm run analyze
Salesforce Code Analyzer v5 scans sfdx-source/checkr and scripts. Its
threshold includes every severity. The runner also checks the engine log and
writes code-analyzer-results.json for inspection. The reference package
contains separately maintained admin smoke seeds and integration tests, so it
stays outside the analyzer scope.
code-analyzer.yml and the files it references explain each override. The
ESLint config applies Node globals and runtime exceptions only to Node scripts.
CPD’s JavaScript extensions omit .mjs because its lexer fails on script
shebangs. The custom PMD rule CheckrMethodNamingConventions permits
subject_behaviour test names and keeps camelCase for production methods.
Tests that assert CRUD, FLS, or sharing behavior use System.runAs with an
inserted test user. Database wiring tests that depend on the administrative
context may use the existing running user. Pure logic and stubbed unit-test
classes document their class-level exception to the PMD runAs rule.
Gate: scripts/gate.mjs
node scripts/gate.mjs runs the local verification gate.
- Runs
npm ci --no-audit --no-fundonly whennode_modulesis absent, as in a fresh worktree. - Runs
npm test. - Runs
npm run analyze -- --if-installed. This skips when the Salesforce CLI or an installed analyzer plugin is absent. A JIT-only listing means the plugin still needs installation. - Checks that
aeris onPATH. - Warns if the local
aerversion differs from the version pinned inscripts/gate.mjs. - Runs
npm run test:apexagainst bothsfdx-source/checkrandsfdx-source/referencewith-p CKR_Admin, with no skips.
The gate never calls an org. Using AER requires a license: without one it stops
at 100 test methods, and the suite has more. Set AER_LICENSE_KEY (never
commit it). Run the local gate before opening a pull request. CI runs the Apex
org validation workflow only after a maintainer enables it; see
Apex validation.
CI: .github/workflows/ci.yml
The lint-and-test job runs on ubuntu-latest with Node 22 and the npm cache.
- Check out the repository.
npm ci.- Download afmt 1.0.0 and add it to
GITHUB_PATH. npm test.
The code-analyzer job uses Node 22, Temurin Java 17, Salesforce CLI
2.158.7, and Code Analyzer 5.13.0. It runs npm run analyze after
installing dependencies. Each pull request must pass both checks.
Apex validation
.github/workflows/apex-validation.yml validates both package directories
using a check-only deployment with RunLocalTests. The apex-validation
job reports the result on the pull request or branch commit. It fails if org
validation is disabled, skipped, or unsuccessful.
To enable this check, a maintainer provisions a dedicated validation org,
creates the protected GitHub environment checkr-apex-validation, and stores
an SFDX auth URL for that org as the environment secret
CHECKR_VALIDATION_AUTH_URL. Limit environment access to reviewed runs and
trusted repository branches. Set the repository variable
CHECKR_ORG_VALIDATION to enabled, run the workflow, and configure branch
protection to require the apex-validation check. The workflow applies to
every pull request so source changes always receive the check. For a fork pull
request, a maintainer reviews the commit and opens a same-repository branch for
validation. Confirm a green check on the release commit before releasing.
Other scripts (outside the gate and CI)
npm run test:lwcis the samesfdx-lwc-jestrunner astest:unit.test:lwc:coverageandtest:unit:coverageadd coverage;test:unit:watchandtest:unit:debugare for local work.npm run test:e2eruns the Playwright suite intests/playwrightagainst a live org, so it is not innpm test, the gate, or CI. It readsSF_BASE_URLand the auth file from.env.playwright(template:.env.playwright.example).npm run test:e2e:setupfills that file from the org alias (SF_ORG_ALIAS, defaultcheckr), andnpm run test:e2e:authsaves the browser sign-in toSF_AUTH_FILE(default.playwright/auth/salesforce.json). Both paths are git-ignored.test:e2e:headedandtest:e2e:uirun the same suite visibly.
Commit and staging hooks
.husky/pre-commitrunslint-staged:- Prettier writes staged web, data, and XML files. For Markdown it runs
Prettier, then
markdownlint-cli2 --fix. - afmt writes staged Apex.
- ESLint runs on staged Aura and LWC JavaScript.
- Related LWC Jest tests run for staged LWC files.
- Prettier writes staged web, data, and XML files. For Markdown it runs
Prettier, then
.husky/commit-msgruns commitlint with@commitlint/config-conventional, so a message such asbad messageis rejected.- The formatting baseline is commit
c728cef, listed in.git-blame-ignore-revs. Pass--ignore-revs-file .git-blame-ignore-revstogit blameto skip it.
Toolchain
| Item | Value | Where |
|---|---|---|
| Node | 22 or later (engines.node is >=22) |
package.json, ci.yml |
| afmt | 1.0.0 on PATH |
ci.yml, README |
| AER | v1.6.23; the local binary must match | scripts/gate.mjs, aer upgrade |
| Salesforce API | 67.0 for sourceApiVersion and every metadata <apiVersion> |
sfdx-project.json, sfdx-source |
AER pin and known tool issues
-
The local Apex gate includes every test in the reference package, including
CKR_SmokeSeedIT,CKR_AuditMaintenanceIT, andCKR_GateBypassIT. Permission tests assign permission sets to a fresh Standard User insiderunAsof the current admin, then exercise behavior inrunAsof that user. Assigning permission sets to the already running user is not reflected by AER. Audit fixtures are created as the admin before switching users. -
The gate pins AER v1.6.23, the latest stable release. Keep the local binary on the same version with
aer upgrade, or install it withbrew install octoberswimmer/tap/aer. -
On 2026-11-25 at API 67.0, v1.6.23 passed all 113 Apex tests, including the 4 user-mode tests that failed on v1.5.4. It also counts each
System.runAsas one DML statement, as a real org does; v1.4.33 does not. A test that asserted zero DML statements insiderunAspassed on v1.4.33 and failed in the org, so assert DML as a delta measured inside therunAsblock. -
On 2026-10-20 at API 67.0, v1.4.32, v1.4.33, and v1.5.10 passed all 100 Apex tests. v1.5.4 failed 4 user-mode tests with “fields being inaccessible”:
CKR_AuditRecordGuardTest:triggersAndSystemInsertandreferencedGateRuleDeletion.CKR_DefaultTemplateVersionServiceTest:directStatusAndPublishedEditsRejectedandreparentingImmutableChildrenRejected.
The same tests pass on v1.5.4 at API 66.0.
-
Earlier pins avoided v1.5.5+ and v1.4.17+ for a
CKR_UserModeITad-hoc delete failure that no longer reproduces. No upstream issue was opened, because the newer releases pass. -
File AER issues at https://github.com/octoberswimmer/aer-dist/issues.
-
AER does not enforce record sharing.
*ITtests that depend on sharing, such asCKR_UserModeITparent Account access, must also pass in a Private-OWD org throughnpm run org:evidence.