Sf testing

From OrcaQubits/agentic-commerce-skills-plugins · View interactive version

Sf testing is an AI agent skill from the GitHub repository OrcaQubits/agentic-commerce-skills-plugins. Test Salesforce Commerce code — B2C (Node.js unit testing, sfcc-ci CI/CD, sandbox management, linting) and B2B (Apex test classes with 75% coverage minimum, Jest for LWC, sf CLI deployment and validation). Use when writing tests or setting up CI/CD.

How to use this skill

Skill file

sf-testing

Before Writing Code

Fetch live docs before writing tests or setting up CI/CD.

  1. Web-search: "Salesforce B2C Commerce testing best practices 2026"
  2. Web-search: "Salesforce Apex testing guide code coverage 2026"
  3. Web-search: "Lightning Web Components Jest testing @salesforce/sfdx-lwc-jest 2026"
  4. Web-search: "sfcc-ci CI/CD pipeline documentation 2026"
  5. Web-fetch: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_testing.htm
  6. Web-fetch the LWC testing guide for current Jest patterns

Conceptual Architecture

Testing Strategy Overview

| 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% |

B2C Commerce Testing

Unit Testing:

Integration 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 |

B2B Commerce Testing

Apex Test Classes:

Test Data Factory Pattern:

@TestSetup
static void setupTestData() {
    // Fetch live docs for TestDataFactory patterns
    // Create accounts, products, orders for tests
}

Mock Callouts:

LWC Jest Testing:

sf 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 |

CI/CD Pipelines

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 |

Performance Testing

Code Examples

// 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');

Best Practices

General Testing

B2C-Specific

B2B-Specific

CI/CD

Fetch the Apex testing guide, LWC Jest documentation, and sfcc-ci CI/CD reference for exact framework versions and configuration before implementing.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.