Giter VIP home page Giter VIP logo

cypress-metamask's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cypress-metamask's Issues

Switching to Custom Network - Fails if config is the same as default Localhost

Description

If you set environment variables (NETWORK_NAME, RPC_URL, and CHAIN_ID) the code follows the logic to create a custom network (

async initialSetup({ secretWords, network, password }) {
const isCustomNetwork =
process.env.NETWORK_NAME && process.env.RPC_URL && process.env.CHAIN_ID;
await puppeteer.init();
await puppeteer.assignWindows();
await puppeteer.metamaskWindow().waitForTimeout(1000);
await puppeteer.metamaskWindow().bringToFront()
if (
(await puppeteer.metamaskWindow().$(unlockPageElements.unlockPage)) ===
null
) {
await module.exports.confirmWelcomePage();
await module.exports.importWallet(secretWords, password);
if (isCustomNetwork) {
await module.exports.addNetwork(network);
} else {
await module.exports.changeNetwork(network);
}
walletAddress = await module.exports.getWalletAddress();
await puppeteer.switchToCypressWindow();
return true;
} else {
await module.exports.unlock(password);
walletAddress = await module.exports.getWalletAddress();
await puppeteer.switchToCypressWindow();
return true;
}
},
). When these parameters are the same as the localhost configuration already set up with MetaMask installations the creation of the customer network fails silently, which causes the setup to hang since it is waiting for the network name to appear as an option (
await puppeteer.waitForText(
mainPageElements.networkSwitcher.networkName,
network.networkName,
);
).

If you are wanting localhost (which was my case) I unset the RPC_URL and CHAIN_ID and this worked as expected.

Thoughts/Suggestions

The localhost network configuration in Metamask assumes localhost:8545 with chain id 1337. If the provided RPC URL uses 0.0.0.0, localhost, or 127.0.0.1 with the port 8545 with the same chain_id the setup of the custom network will fail. If these match it should not attempt to add a custom network and instead update the network to use localhost instead.

Cannot read property 'bringToFront' of undefined

Details of the issue: Basically, the functionality of switching between the main cypress window and the metamask window fails way too often. When it happens, I get nice results like this:
image

So, the question is: Can we have a better way to detect displayed window and switch accordingly?

Thanks in advance for your help!

Typescript support

Thanks for the good work!

As a feature request, is it possible that this library adds a type definition (augmentation) of the custom methods added to cypress to use this library into an e2e cypress setup built with typescript?

Thanks in advance for helping me out with this!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.