Key Changes and Improvements
v4’s core change is the browser caching mechanism. Instead of setting up MetaMask for each test, v4 pre-configures a browser instance and reuses it, leading to drastically faster test runs. This also enables full support for Playwright. Here’s a summary of the most important changes:-
Installation: The package name remains the same:
@synthetixio/synpress. -
Configuration (
cypress.config.ts): The setup within your Cypress configuration file has changed. You now useconfigureSynpressForMetaMask(orconfigureSynpressForEthereumWalletMock) to integrate Synpress. -
Support Files (
support/e2e.ts): You now import specific command sets (synpressCommandsForMetaMaskorsynpressCommandsForEthereumWalletMock) instead of a global import. -
Test Structure: The automatic page visit in
before()hook, which was a recommended approach, is now replaced with test isolation set tofalse. - API Changes: Several Cypress commands have been renamed or removed for clarity and consistency. A detailed mapping is provided below.
-
Test Execution: You use the standard
cypress runcommand, but headed mode is currently required on CI. -
Wallet Setup Files: Synpress v4 introduces “wallet setup files” (
*.setup.{ts,js,mjs}) to define how the wallet should be pre-configured (importing a seed phrase, adding networks, etc.).
Migration Steps
1. Update Dependencies
Update bothcypress and @synthetixio/synpress to their latest versions. Synpress v4 requires Cypress v13+.
2. Update cypress.config.ts
Replace the old Synpress/Cypress configuration with the new configureSynpressForMetaMask function. If you were using the Ethereum Wallet Mock, use configureSynpressForEthereumWalletMock instead.
3. Update Support File (src/cypress/support/e2e.ts)
Import synpressCommandsForMetaMask and remove any previous global imports of Synpress commands.
Remove cy.visit('/'), because it’s not needed, thanks to test isolation being set to false.
mockEthereum function and call it.
4. Update TypeScript Configuration (tsconfig.json)
Ensure your tsconfig.json is configured for Cypress and includes the necessary files:
"strict": true is set in the compilerOptions.
5. Update Test Files
- Update Commands: Replace v3 commands with their v4 equivalents. See the “Detailed API Changes” section below for a comprehensive mapping.
-
Example:
6. Create Wallet Setup Files (New in v4)
This is a crucial step in Synpress v4. You need to create one or more wallet setup files to define how MetaMask should be pre-configured.-
Create a Directory: By default, Synpress expects these files in
test/wallet-setup. You can change this using the Synpress CLI. -
File Naming: Files must follow the pattern
*.setup.{ts,js,mjs}(e.g.,basic.setup.ts,connected.setup.ts). -
File Content: Use the
defineWalletSetupfunction to define the setup steps.This example imports a wallet using a seed phrase. You can customize this to:- Import from a private key.
- Add custom networks.
- Connect to a dapp (for a “pre-connected” state).
- Change MetaMask settings.
- …and anything else you can do within the MetaMask UI.
7. Build the Cache
After creating your wallet setup files, you must build the cache using the Synpress CLI:- Find your
*.setup.{ts,js,mjs}files. - Generate a unique hash for each setup function.
- Launch a browser instance for each unique setup.
- Execute the setup function (installing MetaMask, importing the wallet, etc.).
- Save the browser context (the cache) to the
.cache-synpressdirectory.
--headless: Run the cache building process in headless mode (no browser window visible). Useful for local development to see what’s happening.--force: Force a rebuild of the cache, even if a cache with the same hash already exists. Use this if you’ve made changes to your setup file or if you suspect the cache is corrupted.--debug: Enables additional logging during the cache building, and preserves logs.[dir]: Specify a custom directory containing the wallet setup files (defaults totest/wallet-setup).
8. Run Your Tests
Now you can run your Cypress tests as usual. Synpress will automatically use the cached browser context.- Headed Mode on CI: Due to a MetaMask issue, you must run tests in headed mode on CI. Use a virtual display like
xvfb-run. See the “Known Issues” page in the Synpress documentation.
Detailed API Changes
This table summarizes the command changes from Synpress v3 to v4:
This migration guide should provide a solid foundation for transitioning your Cypress tests to Synpress v4. Remember to consult the official Synpress documentation and examples for the most up-to-date information and best practices.

