Skip to content

Instantly share code, notes, and snippets.

@dennmart
Created June 23, 2020 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dennmart/ffd802b268555cc85b2c98d398307ada to your computer and use it in GitHub Desktop.
Save dennmart/ffd802b268555cc85b2c98d398307ada to your computer and use it in GitHub Desktop.
Example on how user roles work in TestCafe
import { Role } from "testcafe";
const user = Role("https://example.com/login", async t => {
// Steps for logging in go here.
});
fixture("My application")
.page("https://example.com/home")
.beforeEach(async t => {
await t.useRole(user);
});
test("My first test", async t => {
// Goes through the login process. After
// successful authentication, it returns to
// https://example.com/home to continue with
// your test.
});
test("My second test", async t => {
// Immediately authenticates you as the user
// without going through the login process. It
// should go to https://example.com/home to
// continue with your test.
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment