Skip to content

Replace live Salesforce tests with fixture recording#48

Merged
WalrusSoup merged 5 commits into
mainfrom
feature/pest-mock-responses
Mar 27, 2026
Merged

Replace live Salesforce tests with fixture recording#48
WalrusSoup merged 5 commits into
mainfrom
feature/pest-mock-responses

Conversation

@tance77
Copy link
Copy Markdown
Member

@tance77 tance77 commented Mar 27, 2026

Summary

  • Replace all live Salesforce API calls in tests with Saloon's MockResponse::fixture() recording system
  • First test run hits the real API and saves responses to JSON fixture files; subsequent runs replay offline
  • Add sandbox Dev Hub instructions to README setup guide

What changed

  • tests/Pest.phpgetAPI() now accepts optional MockClient, authenticates with real credentials when available (for recording), falls back to mock token when not (for replay)
  • All 9 test files — Use MockClient + MockResponse::fixture() per test instead of live API calls
  • 53 fixture files — Real Salesforce responses recorded from scratch org in tests/fixtures/responses/
  • README.md — Added --instance-url flag for sandbox Dev Hub login

Test results

  • 88 tests, 121 assertions passing
  • First run (recording from live org): ~19s
  • Subsequent runs (fixture replay): ~3.4s
  • No .env, .authenticator, or scratch org needed to run tests

To re-record fixtures

Delete the fixture files and run with valid credentials:

rm -rf tests/fixtures/responses/
composer test

WalrusSoup and others added 3 commits March 27, 2026 08:54
Add --instance-url flag for sandbox login and note about
automatic Dev Hub targeting in scratch org setup steps.
Use MockClient + MockResponse::fixture() to record real Salesforce
responses on first run and replay them offline afterward. No scratch
org or credentials needed to run tests going forward.
@tance77 tance77 requested a review from WalrusSoup March 27, 2026 16:37
tance77 added 2 commits March 27, 2026 09:41
No live Salesforce connection needed — tests replay from recorded
fixture files checked into the repo.
Copy link
Copy Markdown
Contributor

@WalrusSoup WalrusSoup left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@WalrusSoup WalrusSoup merged commit 603321f into main Mar 27, 2026
2 checks passed
@WalrusSoup WalrusSoup deleted the feature/pest-mock-responses branch March 27, 2026 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants