example.spec.ts
Import
First, you need to import the necessary modules and setup:testWithSynpress
function takes the MetaMask fixtures as an argument, which includes your wallet setup configuration. This setup defines how your wallet should be configured before each test.
Define your test
Now that you have your test instance configured, you can write your test:context
: Playwright browser contextpage
: The page where your dApp is runningmetamaskPage
: The MetaMask extension pageextensionId
: The ID of the MetaMask extension
MetaMask
class. For detailed information about the constructor and available methods, see the MetaMask API reference.
If you’re using the same wallet setup in multiple test files, you can speed up the process of writing your tests by defining a custom fixture that will create the
MetaMask
instance for you.Running Tests
To run your tests:Currently, Synpress runs tests in headed mode by default (like This default behavior will be changed in a future release to match Playwright’s standard behavior.
playwright test --headed
).
To run in headless mode, set the HEADLESS
environment variable:Synpress supports all Playwright features, including: