Role.anonymous Method

Returns an anonymous role. When you enable an anonymous role, TestCafe empties the authentication data storage and logs the user out.

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();
});