sf-testing
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.
Best use case
sf-testing is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
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.
Teams using sf-testing should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/sf-testing/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How sf-testing Compares
| Feature / Agent | sf-testing | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
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.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
SKILL.md Source
# 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:**
- Framework: Mocha or Jest for JavaScript cartridge logic
- Mocking: mock `dw.*` API stubs (dw.system, dw.catalog, dw.order) via proxyquire or jest.mock
- Test scope: controllers, models, helper scripts
- Coverage: nyc or istanbul; aim for 80%+ on business logic
**Integration Testing:**
- Test SCAPI endpoints against development/staging sandbox
- Validate full checkout flow, product search, account management
- Use sandbox-specific test data
**Linting and Code Quality:**
- ESLint with SFCC-specific configuration
- Enforce cartridge naming conventions and API usage patterns
**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:**
- Annotate with `@IsTest`; minimum 75% coverage enforced by Salesforce
- Aim for 85%+ on critical business logic
- Use `@TestSetup` for shared test data across methods
- Assertions: `System.assert()`, `System.assertEquals()`, `System.assertNotEquals()`
**Test Data Factory Pattern:**
```apex
@TestSetup
static void setupTestData() {
// Fetch live docs for TestDataFactory patterns
// Create accounts, products, orders for tests
}
```
**Mock Callouts:**
- `HttpCalloutMock` interface for external HTTP callouts
- `StaticResourceCalloutMock` for static response data
- Register mocks via `Test.setMock()`
**LWC Jest Testing:**
- Framework: `@salesforce/sfdx-lwc-jest`
- Wire adapter mocking for `@wire` decorated properties
- Imperative Apex method mocking via `jest.mock`
- DOM querying and assertion on rendered component output
- Custom event and standard event testing
**sf CLI Deployment Validation:**
```bash
# 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
- Load testing: simulate concurrent users against sandbox (Artillery, JMeter)
- Stress testing: identify breaking points under extreme load
- Establish baseline metrics; run performance tests on schedule
## Code Examples
```javascript
// Pattern: B2C controller unit test
// Fetch live docs for proxyquire and dw.* mock patterns
// proxyquire('./Controller', {'dw/catalog/ProductMgr': mock})
// assert result matches expected
```
```apex
// 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
- Write tests alongside feature development, not after
- Automate testing in every deployment pipeline
- Mock all external dependencies in unit tests
- Generate and archive test result reports
### B2C-Specific
- Mock `dw.*` APIs; never rely on live Salesforce APIs in unit tests
- Isolate controller logic from views for testability
- Use dedicated sandboxes for automated testing
- Store tests alongside cartridge code in version control
### B2B-Specific
- Bulkify test data (200+ records) to verify governor limit compliance
- Test error handling and edge cases (negative testing)
- Use `System.runAs()` for user context and permission testing
- Test LWC keyboard navigation and ARIA attributes for accessibility
### CI/CD
- Trigger tests on every commit; fail builds on test failure
- Maintain rollback plans for failed deployments
- Keep dev/staging/production configurations aligned
- Alert team immediately on test failures
Fetch the Apex testing guide, LWC Jest documentation, and sfcc-ci CI/CD reference for exact framework versions and configuration before implementing.Related Skills
woo-testing
Test WooCommerce extensions — PHPUnit unit/integration tests, WP test suite, WooCommerce test helpers, E2E with Playwright, and WP-CLI test scaffolding. Use when writing tests for WooCommerce plugins or setting up a test environment.
webmcp-testing
Test WebMCP tools with AI agents — Chrome DevTools integration, agent testing workflows, tool discovery verification, and end-to-end commerce flow testing. Use when validating that tools work correctly with real AI agents.
spree-testing
Test Spree applications and extensions with RSpec — `spree_dev_tools` gem (v5.2+) for factories and helpers, FactoryBot patterns (prefer `build` over `create`), Capybara feature specs, controller/request specs, testing decorators and subscribers, dummy app for extension testing, system specs for the Hotwire admin, and CI patterns. Use when writing Spree tests, setting up CI, or refactoring slow specs.
shopify-testing
Test Shopify applications — app testing with Vitest and Playwright, theme testing with Theme Check, Function testing, webhook testing, extension testing, and CI/CD pipelines. Use when writing tests for Shopify projects.
saleor-testing
Test Saleor applications — pytest setup, Django test client, GraphQL test patterns, App testing, factory_boy fixtures, and webhook testing. Use when writing tests for Saleor projects.
medusa-testing
Test Medusa v2 applications — Jest setup, module unit tests, workflow integration tests, API route tests, medusaIntegrationTestRunner, and mock patterns. Use when writing tests for Medusa projects.
php-testing
Write PHP tests with PHPUnit — unit tests, mocking, data providers, test doubles, assertions, and TDD practices. Use when writing tests for PHP code, whether in Magento or standalone PHP applications.
magento-testing
Write tests for Magento 2 — PHPUnit unit tests, integration tests, MFTF functional tests, and API tests. Use when implementing test coverage for modules, debugging, or setting up CI/CD test pipelines.
bc-testing
Test BigCommerce integrations — API testing, Stencil theme testing, Cypress/Playwright E2E tests, webhook testing, and sandbox stores. Use when writing tests for BigCommerce apps, themes, or integrations.
a2a-testing
Test A2A implementations — unit tests, integration tests, mock agents, protocol conformance, and end-to-end multi-agent testing. Use when building test suites for A2A servers, clients, or multi-agent systems.
woo-shipping
Build WooCommerce shipping methods — WC_Shipping_Method, shipping zones, shipping classes, rate calculation, tracking, and integration with carriers. Use when creating custom shipping integrations or configuring shipping logic.
woo-setup
Install WooCommerce, configure the development stack, and set up a local dev environment with WP-CLI, Docker, or wp-env. Use when setting up a new WooCommerce project or development environment.