taiko
taiko copied to clipboard
evaluate returns empty object when function throws
Describe the bug
const x = await evaluate(() => {
return document.querySelector('.doesNotExist').textContent
})
When no element with class doesNotExist exists x will have value {}. I think this is because it's a json-ified error.
To Reproduce
const { openBrowser, evaluate, goto } = require('taiko');
openBrowser();
goto('https://example.com')
const x = await evaluate(() => {
return document.querySelector('.doesNotExist').textContent
})
console.log(x);
Expected behavior
evaluate should throw when the client function throws. It might require wrapping the function and returning an either type which includes the message and the stack of the error.