pageCompleteCheck doesn't work when passing a script file as an argument
Hi there,
The documentation here (https://www.sitespeed.io/documentation/browsertime/configuration/) says that a script file can be passed but it doesn't work. The script inside the file is never executed. I know I can use inline JS but just wanted to raise the inconsistency. I'm using the docker version on Ubuntu 18.04.
Also, this unit test here (https://github.com/sitespeedio/browsertime/blob/34ecdc435aa9c481e723436da3a61e2dbf2e3efd/test/browserTests/engineTests.js#L239) seems to indicate that a script file is indeed supported?
Hi @harshavarma can you add an example how you run so I can easily reproduce? Thanks Peter
Hi Peter,
This is what I'm currently using and it works as expected.
docker run --rm -v "$(pwd)":/sitespeed.io ${DOCKER_IMAGE} ${WEBSITE_URL} -n 1 --browsertime.pageCompleteCheck "return document.querySelector('.btn--primary') != null"
However, if I move the same inline code to a file, it doesn't. I tried wrapping it in a IIFE and it still didn't work.
docker run --rm -v "$(pwd)":/sitespeed.io ${DOCKER_IMAGE} ${WEBSITE_URL} -n 1 --browsertime.pageCompleteCheck pageCompleteCheck.js
Also, the inline code fails when I use
docker run --rm -v "$(pwd)":/sitespeed.io ${DOCKER_IMAGE} ${WEBSITE_URL} -n 1 --browsertime.pageCompleteCheck "return !!document.querySelector('.btn--primary')"
The !! operator seems to be causing an issue. I tried escaping it but when I used --verbose mode, I saw that the escape characters are getting escaped.
Hi @harshavarma I think the docs are wrong or the code, sorry. There's a miss there, I can't see in the code that we actually try to read the file. I'll try to fix that for the next release.
Best Peter
This was fixed but then broken again when we moved to ESM.
This has finally been fixed again in BT 20.