Skip to content

Commit

Permalink
Enable setup of the keplr extension in the beforeAll hook for cypress (
Browse files Browse the repository at this point in the history
…#14)

* fix: added code to handle setup of keplr wallet beforehand

* chore: lint fixes
  • Loading branch information
frazarshad authored Mar 5, 2024
1 parent e6c340e commit 6e2b5c4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
12 changes: 10 additions & 2 deletions plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,18 @@ module.exports = (on, config) => {
} else if (extension === 'keplr') {
selectedConfig = require('./keplr-plugin');
} else {
throw new Error(
`${extension} is not a valid extension name`,
throw new Error(`${extension} is not a valid extension name`);
}

if (process.env.SKIP_EXTENSION_SETUP) {
config.env.SKIP_EXTENSION_SETUP = JSON.parse(
process.env.SKIP_EXTENSION_SETUP,
);
}

if (process.env.EXTENSION) {
config.env.EXTENSION = process.env.EXTENSION;
}

return selectedConfig(on, config);
};
11 changes: 9 additions & 2 deletions support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@ Cypress.on('window:before:load', win => {
});

before(() => {
if (Cypress.env('EXTENSION') === 'metamask' && !Cypress.env('SKIP_EXTENSION_SETUP')) {
cy.setupMetamask();
if (!Cypress.env('SKIP_EXTENSION_SETUP')) {
switch (Cypress.env('EXTENSION')) {
case 'metamask':
cy.setupMetamask();
break;
case 'keplr':
cy.setupWallet();
break;
}
}
});

0 comments on commit 6e2b5c4

Please sign in to comment.