-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: MetaMask setup in Cypress (#1157)
* feat: MetaMask setup in Cypress part 1 * feat: wallet setup is working as expected * fix: gitignore cleanup * fix: clean imports * fix: export from metamask package * fix: dependencies issues * fix: cleanup * fix: test scripts * fix: format * fix: renamed configureBeforeSynpress.ts to configureSynpress.ts * fix: metamask output dir
- Loading branch information
Showing
149 changed files
with
653 additions
and
314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from '@synthetixio/ethereum-wallet-mock/cypress' | ||
export * from '@synthetixio/synpress-metamask/cypress' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from '@synthetixio/ethereum-wallet-mock/playwright' | ||
export { MetaMask, getExtensionId, metaMaskFixtures } from '@synthetixio/synpress-metamask' | ||
export * from '@synthetixio/synpress-metamask/playwright' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export { default as installSynpress } from './utils/installSynpress' | ||
export { default as configureSynpress } from './utils/configureSynpress' | ||
export { default as EthereumWalletMock } from './EthereumWalletMock' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { defineConfig } from 'cypress' | ||
import configureSynpress from './src/cypress/configureSynpress' | ||
|
||
export default defineConfig({ | ||
chromeWebSecurity: false, | ||
e2e: { | ||
baseUrl: 'http://localhost:9999', | ||
specPattern: 'test/cypress/**/*.cy.{js,jsx,ts,tsx}', | ||
supportFile: 'src/cypress/support/e2e.{js,jsx,ts,tsx}', | ||
testIsolation: false, | ||
async setupNodeEvents(on, config) { | ||
return configureSynpress(on, config) | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { lockPage } from '../selectors' | ||
import { MetaMaskAbstract } from '../type/MetaMaskAbstract' | ||
|
||
// @ts-ignore | ||
// TODO: To be implemented | ||
export class MetaMask extends MetaMaskAbstract { | ||
unlock() { | ||
cy.get(lockPage.passwordInput).type(this.password) | ||
cy.get(lockPage.submitButton).click() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ensureRdpPort } from '@synthetixio/synpress-core' | ||
import importMetaMaskWallet from './support/importMetaMaskWallet' | ||
import { initMetaMask } from './support/initMetaMask' | ||
|
||
let port: number | ||
|
||
export default function configureSynpress(on: Cypress.PluginEvents, config: Cypress.PluginConfigOptions) { | ||
const browsers = config.browsers.filter((b) => b.name === 'chrome') | ||
if (browsers.length === 0) { | ||
throw new Error('No Chrome browser found in the configuration') | ||
} | ||
|
||
on('before:browser:launch', async (_, launchOptions) => { | ||
// Enable debug mode to establish playwright connection | ||
const args = Array.isArray(launchOptions) ? launchOptions : launchOptions.args | ||
port = ensureRdpPort(args) | ||
|
||
args.push(...(await initMetaMask())) | ||
|
||
return launchOptions | ||
}) | ||
|
||
on('before:spec', async () => { | ||
await importMetaMaskWallet(port) | ||
}) | ||
|
||
return { | ||
...config, | ||
browsers | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './MetaMask' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// *********************************************************** | ||
// This example support/e2e.ts is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import synpressCommands from './synpressCommands' | ||
|
||
before(() => { | ||
cy.visit('/') | ||
}) | ||
|
||
Cypress.on('uncaught:exception', () => { | ||
// failing the test | ||
return false | ||
}) | ||
|
||
synpressCommands() |
Oops, something went wrong.