ClientFunction Object

A client function that can return any serializable value from the client side.

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 `My fixture`
    .page `http://www.example.com/`;

test('My Test', async t => {
    const location = await getWindowLocation();
});

You can overwrite client function options via the ClientFunction's with method.

For more information, see Obtain Client-Side Info.