How to Run End-to-End Tests for Payment Flows in the Adyen SFCC Integration
To run end-to-end tests for payment flows in the Adyen SFCC integration, configure your sandbox credentials in a .env file and execute npm run test:e2e from the repository root, which triggers the Playwright suite against your specified SFRA version.
The adyen/adyen-salesforce-commerce-cloud repository includes a comprehensive Playwright-based testing framework that validates complete checkout experiences across SFRA versions. This suite exercises real payment flows including redirects, QR codes, and post-payment validation using the same code paths executed in production environments.
Prerequisites and Environment Configuration
Before executing any tests, you must prepare your local environment and obtain valid Salesforce Commerce Cloud sandbox credentials.
Required Environment Variables
The test runner reads configuration from a .env file located at the repository root. Create this file by copying the provided .env.example and populate the following required variables:
# SFRA version to test: v5.3.0, v6.1.0, or v7.0.0
SFRA_VERSION=v6.1.0
# SFCC sandbox connection details
SFCC_HOSTNAME=my-sandbox.demandware.net
SANDBOX_HTTP_AUTH_USERNAME=yourUsername
SANDBOX_HTTP_AUTH_PASSWORD=yourPassword
# Optional: Third-party payment credentials
PAYPAL_USERNAME=paypalUser
PAYPAL_PASSWORD=paypalPass
AMAZONPAY_USERNAME=amazonUser
AMAZONPAY_PASSWORD=amazonPass
The tests/playwright/sfcc.config.js file consumes these variables via process.env to configure the Playwright baseURL, HTTP authentication, and timeout settings.
Node.js Version Requirements
You must use Node.js version 14 or later, matching the node_version parameter defined in the .github/workflows/E2E_template.yml CI workflow. Use nvm to switch to the appropriate version if necessary.
End-to-End Test Architecture
Understanding the test structure helps when debugging failures or extending coverage.
Core Components
- Configuration:
tests/playwright/sfcc.config.jsinitializes the Playwright test runner withrequire('dotenv').config()and defines project settings for Chromium. - Environment Selector:
tests/playwright/data/environments.mjsconstructs an array of test environments based onSFRA_VERSION, supplying the appropriate checkout page class (e.g.,CheckoutPageSFRA5,CheckoutPageSFRA6) and base URL fragments. - Page Objects: Files in
tests/playwright/pages/*.mjsencapsulate UI interactions, exposing methods likegoToCheckout()andsetShopperDetails(). - Payment Flow Helpers:
tests/playwright/paymentFlows/*.mjsorchestrate complex multi-step flows such as pending redirects and QR-code handling. - Test Specifications:
tests/playwright/fixtures/**/*.spec.mjscontain the actual test cases, iterating over configured environments to validate specific payment methods like MBWay or MultiBanco.
Installing Dependencies
Navigate to the Playwright directory and install the exact dependency versions recorded in the lockfile:
cd tests/playwright
npm ci
npx playwright install --with-deps
These commands correspond to the "install e2e test dependencies" and "setup playwright dependencies" steps in the GitHub Actions workflow.
Executing the Test Suite
The repository provides several npm scripts to accommodate different testing scenarios.
Running the Full Suite
Execute all end-to-end tests across configured browsers:
npm run test:e2e
This command, defined in the root package.json, changes to the tests/playwright directory and invokes the test script.
CI-Optimized Execution
For faster feedback during continuous integration, use the Chromium-only configuration:
npm run test:e2e:ci
This executes npm run test:ci from tests/playwright/package.json, which enforces the chromium project and matches the behavior of .github/workflows/E2E_template.yml.
Quick Smoke Tests
Run only tests marked with the @quick tag for rapid validation:
npm run test:e2e:quick
Filtering Specific Payment Flows
To validate a single payment method (e.g., BCMC Mobile QR codes), use the -g flag to filter by test title:
npm run test:e2e -- -g "BCMC Mobile"
Analyzing Test Results and Debugging
Playwright generates detailed artifacts to diagnose failures.
HTML Reports
After execution, open tests/playwright/test-results/report.html to view a breakdown of results per payment method and SFRA version. This report is configured in sfcc.config.js as the default reporter output.
Trace Files
When tests fail, Playwright retains trace.zip files containing step-by-step execution details. Open these with:
npx playwright show-trace test-results/<test-name>/trace.zip
This mirrors the trace: 'retain-on-failure' setting used in CI environments.
Troubleshooting Common Configuration Issues
| Symptom | Root Cause | Solution |
|---|---|---|
| "Missing env variable" error | .env file not loaded |
Ensure the file exists at the repository root and contains all keys referenced in sfcc.config.js. |
| Connection timeout to sandbox | Incorrect SFCC_HOSTNAME |
Verify the hostname excludes the https:// protocol prefix; the configuration adds this automatically. |
| Third-party redirect failures | Missing wallet credentials | Add PAYPAL_USERNAME and PAYPAL_PASSWORD to .env, or disable specs with test.fixme. |
test.only error in CI |
Debug code left in specs | Remove test.only from spec files; the CI sets forbidOnly: !!process.env.CI. |
Summary
- The Adyen SFCC integration uses Playwright to validate payment flows across SFRA v5.3.0, v6.1.0, and v7.0.0.
- Configuration is driven by environment variables in a
.envfile consumed bytests/playwright/sfcc.config.js. - Execute
npm run test:e2eto run the full suite locally, matching the CI pipeline defined in.github/workflows/E2E_template.yml. - Use
-gflags to filter specific payment methods andtrace.zipfiles to debug failures. - Third-party flows require additional credentials for PayPal, AmazonPay, or GooglePay.
Frequently Asked Questions
Which SFRA versions are supported for end-to-end testing?
The test suite supports SFRA v5.3.0, v6.1.0, and v7.0.0. Set the SFRA_VERSION environment variable to one of these values before running tests; the tests/playwright/data/environments.mjs file automatically configures the appropriate page objects and URLs for that version.
How do I run tests for only one specific payment method?
Append the -g flag followed by the payment method name to the test command: npm run test:e2e -- -g "iDEAL". This filters the test collection to match only specs containing that string in their title or tags.
What credentials are required for testing third-party wallets?
For PayPal, AmazonPay, or GooglePay flows, you must provide PAYPAL_USERNAME, PAYPAL_PASSWORD, AMAZONPAY_USERNAME, AMAZONPAY_PASSWORD, and corresponding Google Pay variables in your .env file. Without these, the redirects to external payment pages will fail authentication.
Where are the test reports located after execution?
Playwright writes an HTML report to tests/playwright/test-results/report.html and retains failure traces in trace.zip files within the test-results/ directory. Open the HTML file in any browser to see a detailed breakdown, or use npx playwright show-trace to inspect step-by-step failures.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →