Window.document.body.scrollHeight retrieved with ClientFunction is not resetting between test runs
fixture`smallpage`
test('smallpageTest', async t => {
//...
const getBodyHeight = ClientFunction(() => window.document.body.scrollHeight);
console.log(`${test} body.scrollHeight`, await getBodyHeight()); // 800px
// ...
longpageTest.js
fixture`longpage`
test('longpageTest', async t => {
//...
const getBodyHeight = ClientFunction(() => window.document.body.scrollHeight);
console.log(`${test} body.scrollHeight`, await getBodyHeight()); // 1200px
//...
When run in that order, it's fine.
smallpageTest body.scrollHeight 800px
longpageTest body.scrollHeight 1200px
However when ran in reverse order (big to small), it seems the scrollHeight
is set to the long side all the time
longpageTest body.scrollHeight 1200px
smallpageTest body.scrollHeight 1200px
My gut is that the test runner is holding onto the state at a global level. I call the tests using an npm
test call (testcafe -firefox:headless *Test.js
) rather than setting up any specific testcafe runner.
Adding -c
for concurrency and passing 2 (as there are two tests) also solves this issue, but theorising only because each of the two tests are executed separately.
Any ideas how I can have the correct sizing independent of the order? Or perhaps a way to reset the scrollHeight between tests?