I have TestCafe running in two separate test classes, in two separate fixtures, in two separate tests, testing two different app pages.
I notice when I interrogate the window.document
object through the ClientFunction
in these tests, depending on the running order, I get differing values.
e.g. mytest1.js
import { Selector, ClientFunction } from 'testcafe';
fixture `Homepage`
.page `http://mypage.com`;
test('Test 1', async t => {
const getBodyHeight = ClientFunction(() => window.document.body.scrollHeight);
console.log(await getBodyHeight()) // 800px
});
mytest2.js
import { Selector, ClientFunction } from 'testcafe';
fixture `Dashboard`
.page `http://mypage.com/dashboard`;
test('Test 2', async t => {
const getBodyHeight = ClientFunction(() => window.document.body.scrollHeight);
console.log(await getBodyHeight()) // 1200px
});
If I run these using npm run testcafe -- firefox:headless mytest*.js
and the order is smaller height to larger height, the console will log:
...
800
...
1200
However if I run these the opposite way (larger height to smaller height), I get:
...
1200
...
1200
It is as if the document.body
is stretched to a max value and doesn't return.
Is there a way using the ClientFunction(..)
or possibly some other means to reset these values correctly?