I am attempting to use testcafé to log into multiple services using testcafé's role-mechanism/concept. My tests need to be logged into multiple services at the same time (i.e. they don't want to switch between roles).
According to this guide (https://devexpress.github.io/testcafe/documentation/guides/advanced-guides/authentication.html), it should be possible to use testcafé with multiple roles. However, my tests only manage to switch between roles (i.e. they are are not logged into multiple services at the same time)
Quote from above guide:
For instance, assume that you switch to a role that logs you in on website A. After you switch to this role, you log in to website B in test code. TestCafe adds a new cookie to the role branch. If you switch to a different role and then back to the initial role in the same test run, you will be logged to both website A and B. If you switch to this role in a different test, you will be logged in to website A only.
Here are my main attempts to accomplish the above, but none of them were successful.
import { Role } from "testcafe";
const role1 = Role("https://some-website.org", async t => {
await t
.typeText("input[type=text]", "")
.typeText("input[type=password]", "")
.click(".button");
});
const role2 = Role("https:/another-website.org", async t => {
await t
.typeText("input[type=text]", "")
.typeText("input[type=password]", "")
.click(".button");
});
fixture `Getting Started`;
test("test 1", async t => {
await t.useRole(role1);
// now logged in as "role1"
await t.useRole(role2);
// now logged in as "role2"
// ... but not logged in as "role1" and "role2"
});
test("test 2", async t => {
await t
.useRole(role1) // now logged in as "role1"
.useRole(role2); // now logged in as "role2"
// ... but not logged in as "role1" and "role2"
});
test("test 3", async t => {
await t
.useRole(role1) // now logged in as "role1"
.useRole(role2) // now logged in as "role2"
.useRole(role1); // now logged in as "role1"
// ... but not logged in as "role1" and "role2"
});
What do I need to do to be logged into multiple services at the same time?
testcafé version: 1.8.8
browser: Chrome 84.0.4147.89 / macOS 10.15.5