Run Tests for Changed Files
Run e2e and unit tests that are relevant to the files changed on the current branch.
Test Configuration
- Unit (Jest): Config in
jest.config.js, path aliases viamoduleNameMapper - E2E (Playwright): Config in
playwright.config.ts, Chromium only, 20s timeout per test, 2 retries, 2 workers - E2E dev server: Playwright starts
pnpm devautomatically, butreuseExistingServer: truein non-CI — a stale server from another branch will cause false failures
Steps
Kill any stale dev server on port 3000 before running e2e tests. Playwright's
reuseExistingServerwill pick up a server from a different branch otherwise, causing false failures (especially in worktrees):lsof -ti:3000 | xargs kill -9 2>/dev/null; trueFind changed files relative to
main:git diff --name-only main...HEAD git diff --name-only # unstaged git diff --name-only --cached # stagedMap source changes to test files. Use these rules:
src/app/(sidebar)/transaction/build/**->tests/e2e/buildTransaction.test.ts,tests/e2e/savedTransactions.test.ts,tests/e2e/urlParams.test.tssrc/app/(sidebar)/transaction/sign/**->tests/e2e/signTransactionPage.test.tssrc/app/(sidebar)/transaction/submit/**->tests/e2e/submitTransactionPage.test.tssrc/app/(sidebar)/transaction/simulate/**->tests/e2e/simulateTransactionPage.test.tssrc/app/(sidebar)/transaction/fee-bump/**->tests/e2e/feeBumpTransactionPage.test.tssrc/app/(sidebar)/account/fund/**orsrc/app/(sidebar)/account/create/**->tests/e2e/fundAccountPage.test.ts,tests/e2e/createAccountPage.test.tssrc/app/(sidebar)/xdr/**->tests/e2e/viewXdrToJsonPage.test.ts,tests/e2e/jsonToXdrPage.test.tssrc/app/(sidebar)/endpoints/**->tests/e2e/endpointsPage*.test.tssrc/app/(sidebar)/smart-contracts/**->tests/e2e/contractExplorer*.test.ts- Shared code — run ALL e2e tests:
src/components/**,src/helpers/**,src/hooks/**,src/store/**,src/constants/**,src/types/**,src/validate/**,src/styles/**,src/middleware.ts tests/e2e/mock/**-> run ALL e2e tests that import from mock/tests/e2e/*.test.tschanged directly -> run those teststests/unit/**changed -> run unit tests- If source files under
src/helpers/orsrc/validate/changed, also checktests/unit/for matching unit tests
If XDR encoding or transaction building logic changed (e.g.
ClassicTransactionXdr.tsx,SorobanTransactionXdr.tsx,src/helpers/xdr/), hardcoded hash/XDR values in tests may need updating. Flag this to the user before running tests.Run the identified tests:
- E2E:
npx playwright test <file1> <file2> ... --retries=0 --reporter=list - Unit:
pnpm test:unit <file> - If no specific tests identified, run the full suite:
pnpm test:e2eandpnpm test:unit
- E2E:
Report results. Show pass/fail counts and list any failures with their error messages. For failures, read the relevant test code and source code to suggest fixes.