/salesforce-commerce:sf-testingfrom salesforce-commerce
Test Salesforce Commerce B2C and B2B code: Node.js unit testing, sfcc-ci CI/CD, Apex test classes (75% coverage), Jest for LWC, sf CLI. Use when writing tests or setting up CI/CD.
Ships in salesforce-commerce. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Fetch live docs before writing tests or setting up CI/CD.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing.htm| Layer | B2C (SFCC) | B2B (Lightning) |
|---|---|---|
| Unit | Mocha/Jest for JS cartridge logic | Apex test classes (@IsTest) |
| Component | N/A | LWC Jest (@salesforce/sfdx-lwc-jest) |
| Integration | SCAPI/OCAPI against sandbox | sf CLI deploy validation |
| E2E | Full checkout flow on sandbox | Full storefront flow on scratch org |
| Linting | ESLint (SFCC config) | ESLint (LWC), Apex PMD |
| Coverage | nyc/istanbul (aim 80%+) | Salesforce enforced minimum 75% |
Unit Testing:
dw.* API stubs (dw.system, dw.catalog, dw.order) via proxyquire or jest.mockIntegration Testing:
Linting and Code Quality:
CI/CD Pipeline (sfcc-ci):
1. sfcc-ci code:deploy -> upload cartridge
2. sfcc-ci code:activate -> activate version
3. npm test -> run unit tests
4. sfcc-ci job:run -> integration tests
Sandbox Management:
| Environment | Purpose |
|---|---|
| Development | Developer-specific feature work |
| Staging | Pre-production validation |
| Production | Controlled release deployment |
Apex Test Classes:
@IsTest; minimum 75% coverage enforced by Salesforce@TestSetup for shared test data across methodsSystem.assert(), System.assertEquals(), System.assertNotEquals()Test Data Factory Pattern:
@TestSetup
static void setupTestData() {
// Fetch live docs for TestDataFactory patterns
// Create accounts, products, orders for tests
}
Mock Callouts:
HttpCalloutMock interface for external HTTP calloutsStaticResourceCalloutMock for static response dataTest.setMock()LWC Jest Testing:
@salesforce/sfdx-lwc-jest@wire decorated propertiesjest.mocksf CLI Deployment Validation:
# Dry-run validation with test execution
sf project deploy start --dry-run --test-level RunLocalTests
# Run specific test classes
sf apex run test --class-names MyTestClass --result-format human
Code Coverage Requirements:
| Threshold | Context |
|---|---|
| 75% minimum | Salesforce deployment requirement (org-wide) |
| 85%+ recommended | Critical business logic (payments, orders) |
| 100% target | Apex triggers (keep triggers thin, test all paths) |
| Per-class tracking | sf apex run test --code-coverage reports per class |
B2C Pipeline (GitHub Actions pattern):
| Step | Command |
|---|---|
| Deploy | sfcc-ci code:deploy cartridge.zip -i $SANDBOX |
| Activate | sfcc-ci code:activate --version $VERSION |
| Test | npm test |
B2B Pipeline (Salesforce CLI pattern):
| Step | Command |
|---|---|
| Deploy | sf project deploy start --target-org staging |
| Test | sf apex run test --test-level RunLocalTests --code-coverage |
| Report | sf apex get test --test-run-id $ID |
// Pattern: B2C controller unit test
// Fetch live docs for proxyquire and dw.* mock patterns
// proxyquire('./Controller', {'dw/catalog/ProductMgr': mock})
// assert result matches expected
// Pattern: B2B Apex test with assertions
// Fetch live docs for @IsTest and System.assertEquals
// Test.startTest(); call method; Test.stopTest();
// System.assertEquals(expected, actual, 'message');
dw.* APIs; never rely on live Salesforce APIs in unit testsSystem.runAs() for user context and permission testingFetch the Apex testing guide, LWC Jest documentation, and sfcc-ci CI/CD reference for exact framework versions and configuration before implementing.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub orcaqubits/agentic-commerce-skills-plugins --plugin salesforce-commerce24 skills in this plugin
/js-modernWrite modern JavaScript and TypeScript — ES6+ features, async/await, modules, destructuring, optional chaining, TypeScript types. Covers SFCC server-side JS (CommonJS, limited ES6), PWA Kit (full modern JS/TS), and LWC JavaScript (Lightning Locker constraints). Use when writing JavaScript for Salesforce Commerce./node-backendBuild Node.js backends for Salesforce Commerce — SFCC server-side JavaScript (not actual Node.js runtime), PWA Kit backend (Express-like SSR server), Commerce SDK for server-side SCAPI access, and async patterns for external service integration. Use when building server-side commerce logic./react-patternsOther plugins' skills for the same job