Closed rkefi closed 1 year ago
Hi @rkefi
You can't compare webdriver io and playright, it's like comparing apples with oranges.
One creates a complete environment within javascript to test javascript in isolation, the other one controls a browser (or a headless browser) from the outside to interact with your application.
In a browser-based test environment (like webdriver io), you need to load web3-mock.js and all mocks with every new page load into the window
object, that the test runner is controlling from the outside. You currently might load web3-mock.js into the runner, not into the front end, which explains why there is no window.ethereum around.
That is what we do in-house with some ruby projects, using capybara and webdrivers gem (similar stack in ruby).
currently for us that looks like this:
page.execute_script([ethers_file, solana_web3_file, web3constants_file, web3blockchains_file, web3client_file, web3tokens_file, web3exchanges_file, web3payments_file, web3mock_file].join(";\n"))
page.execute_script(%Q<
window.Web3Mock.mock({ blockchain: #{blockchain.to_json}, accounts: { return: #{accounts.to_json} } })
window.Web3Mock.mock({ provider: await window.Web3Client.getProvider(#{blockchain.to_json}), blockchain: #{blockchain.to_json}, accounts: { return: #{accounts.to_json} } })
>)
Hi @10xSebastian Thanks for the quick response and the details Will test that! Thanks!
Hi,
I was trying to use web3-mock with webdriver io , but no success so far. Followed the config for playright mainly but the window.ethereum was not reconized
Could you please help with this integration? Thanks