I am using TestCafe for my E2E testing.
Scenario: I am running a test use test runs. For example, first test run executes tests in firefox browser, and next run in chrome (this is just example, I have cases where I need to run e2e tests in different stages as well). I have used a role. When one test run completes, and it is running another test run, still the role cookie persists, and it acts as the user is logged in.
Expected behavior: Roles should be re-initialized for each run.
Is there some way I can clean the cookie, or un-initialize the roles?
The
Rolefunctionality was created to save time by saving the state of cookies and (local|session)Storage and applying them on the second and subsequent role calls. If you want to perform login actions on each test, just transfer the actions from your role to a separate function and call this function instead of the role. If your goal is different, please add the example that illustrates the current behavior and describe what task you would like to accomplish.User Roles documentation.