glamorous-country-57678
08/19/2022, 1:52 PMcy.intercept(). The full intercept is here:
cy.intercept(`${ethProvider}*`, (req) => {
// conditonal logic to return different responses based on the request url
console.log(req.body)
const { method, params, id } = req.body
if (method === 'eth_chainId') {
req.reply({
body: {
id: 1,
jsonrpc: '2.0',
result: '0x111111',
},
})
} else if (
method === 'eth_call' &&
params[0]?.data === '0x79502c55'
) {
req.reply({
body: {
id,
jsonrpc: '2.0',
result:
'0x' +
Array(10 * 64)
.fill(0)
.map((_, i) => (i % 64 === 63 ? 1 : 0))
.join(''),
},
})
} else if (method === 'eth_call') {
// other uint256 retrievals
req.reply({
body: {
id,
jsonrpc: '2.0',
result: '0x0000000000000000000000000000000000000000000000000000000000000001',
},
})
} else {
req.reply({
body: { test: 'test' },
})
}
}).as('ethProvider')
I did read the docs on Conditional Testing (https://docs.cypress.io/guides/core-concepts/conditional-testing#:~:text=The%20problem%20is,overcome%20these%20problems...) but want to know if this is the reason requests are thrown like this.