Created
June 23, 2020 03:28
-
-
Save dennmart/ffd802b268555cc85b2c98d398307ada to your computer and use it in GitHub Desktop.
Example on how user roles work in TestCafe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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