ClientFunction Object
Client Functions execute client-side JavaScript code.
Use the ClientFunction constructor to create a client function.
import { ClientFunction } from 'testcafe';
const getWindowLocation = ClientFunction(() => window.location);
Call the client function with the await
keyword to execute it.
import { ClientFunction } from 'testcafe';
const getWindowLocation = ClientFunction(() => window.location);
fixture`ClientFunction`
.page`https://devexpress.github.io/testcafe/example/`;
test('Check location', async t => {
const location = await getWindowLocation();
await t.expect(location.href).eql('https://devexpress.github.io/testcafe/example/');
});
Use the with method to override ClientFunction options.
For more information, read the Client Functions guide.