From salesforce-commerce
Guides Salesforce Commerce testing: B2C Node.js units (Mocha/Jest), sfcc-ci CI/CD, linting, sandboxes; B2B Apex classes (75%+ coverage), LWC Jest, sf CLI validation. For tests/CI/CD.
npx claudepluginhub orcaqubits/agentic-commerce-skills-plugins --plugin salesforce-commerceThis skill is limited to using the following tools:
**Fetch live docs before writing tests or setting up CI/CD.**
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Guides MCP server integration in Claude Code plugins via .mcp.json or plugin.json configs for stdio, SSE, HTTP types, enabling external services as tools.
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.