Example of multi-window Playwright testing with Electron
git clone https://github.com/spaceagetv/electron-playwright-example.git
cd electron-playwright-example
npm install
npm run e2e
This example uses Electron Forge configured to build with Webpack. Since we're testing the .webpack code, this test does a npm run package
to prepare the code before each npm run e2e
.
Note also that nodeIntegration
is enabled and contextIsolation
is disabled when the CI
environment variable is set to "1". This allows us to maintain recommended Electron security for our distributed app, while allowing us greater access while testing.
Find the tests in the e2e-tests
directory.
Tests:
- The first window is loaded
- Button exists on the page
- Clicking the button opens a new window
- Check the title of the new window
- Trigger an IPC listener directly in the main process
- Send an IPC message from the renderer
- Receive IPC invoke/handle via renderer
- Click a menu item in the main process
- Make sure two screenshots match one another