-
-
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: Added Cypress example (#1151)
- Loading branch information
Showing
14 changed files
with
127 additions
and
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { installSynpress } from '@synthetixio/synpress/cypress' | ||
import { defineConfig } from 'cypress' | ||
|
||
export default defineConfig({ | ||
chromeWebSecurity: false, | ||
e2e: { | ||
baseUrl: 'http://localhost:9999', | ||
specPattern: 'test/cypress/**/*.cy.{js,jsx,ts,tsx}', | ||
supportFile: 'test/cypress/support/e2e.{js,jsx,ts,tsx}', | ||
testIsolation: false, | ||
async setupNodeEvents(on, config) { | ||
return installSynpress(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
it('should mock MetaMask in the Test Dapp', () => { | ||
cy.connectToDapp() | ||
|
||
cy.get('#getAccounts').click() | ||
|
||
cy.get('#getAccountsResult').should('have.text', '0xd73b04b0e696b0945283defa3eee453814758f1a') | ||
}) | ||
|
||
it('should add new account using MetaMask mock', () => { | ||
cy.switchAccount('0x4444797cA71d0EaE1be5a7EffD27Fd6C38126801') | ||
|
||
cy.get('#getAccounts').click() | ||
|
||
cy.get('#getAccountsResult').should('have.text', '0x4444797cA71d0EaE1be5a7EffD27Fd6C38126801') | ||
}) |
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,25 @@ | ||
// *********************************************************** | ||
// 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 { mockEthereum, synpressCommands } from '@synthetixio/synpress/cypress/support' | ||
|
||
synpressCommands() | ||
mockEthereum() | ||
|
||
Cypress.on('uncaught:exception', () => { | ||
// failing the test | ||
return false | ||
}) |
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
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 '@synthetixio/ethereum-wallet-mock/cypress/support' |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as mockEthereum } from './mockEthereum' | ||
export { default as synpressCommands } from './synpressCommands' |
20 changes: 11 additions & 9 deletions
20
wallets/ethereum-wallet-mock/src/cypress/support/mockEthereum.ts
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,10 +1,12 @@ | ||
before(() => { | ||
cy.visit('/', { | ||
onBeforeLoad: (window) => { | ||
window.Web3Mock.mock({ | ||
blockchain: 'ethereum', | ||
wallet: 'metamask' | ||
}) | ||
} | ||
export default function mockEthereum() { | ||
before(() => { | ||
cy.visit('/', { | ||
onBeforeLoad: (window) => { | ||
window.Web3Mock.mock({ | ||
blockchain: 'ethereum', | ||
wallet: '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
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