Role.anonymous Static Method

Returns an anonymous role that logs out the user when activated.

Role.anonymous()

Call the t.useRole method to activate an anonymous role:

import { Role, Selector } from 'testcafe';

const payingUser = Role('http://example.com/login', async t => {
    // Log in...
});

fixture `My Fixture`
    .page `http://example.com/`;

test('Paid content is displayed for paying users', async t => {
    await t
        .useRole(payingUser)
        .expect(Selector('#paid-content').visible).ok()
        .useRole(Role.anonymous())
        .expect(Selector('#paid-content').visible).notOk();
});