Not possible to read value returned from Chromy
- Dominant language
- JavaScript
- Stars
- 7.2k
- Forks
- 621
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
according to Chromy documentation, something like this should be possible:
```
const Chromy = require('chromy')
async function main () {
let chromy = new Chromy()
await chromy.goto('http://example.com/')
const result = await chromy.evaluate(() => {
return document.querySelectorAll('*').length
})
console.log(result)
await chromy.close()
}
main()
```
Therefor I would expect something like this should be possible within BackstopJs:
```
async function myFunction(chromy, scenario, vp) {
const result = await chromy.evaluate(() => {
return document.querySelectorAll('*').length
})
console.log(result)
};
module.exports = myFunction;
```
But I am getting this error:
```
(node:15120) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: 'then' is not defined on a target object.
(node:15120) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
```
Any idea what I might doing wrong?
Contributor guide
Research direction
Start by reproducing the custom scenario function with Chromy’s evaluate call and trace how BackstopJS handles the returned value or promise. Compare that path with the Chromy documentation example and inspect the scenario callback entry point mentioned in the issue. Done means the evaluated element count can be read and logged without the 'then' rejection.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100