3

I am curious about behind the scenes logic of Roles. I do understand they do some cookies and local storage magic and I am guessing there is some window magic involved as well

I am guessing that because in one of our tests one of our window properties is disappearing, however without any code actively removing it. So I assume the Roles after login will create a snapshot which is then being reapplied on top of every test case using useRole()

Any idea where could I find more details about this behavior, and how to instruct the testcafe to wait for a particular action to finish before taking that snapshot?

All the examples are finishing the test by clicking on signInButton, I was thinking about waiting for an element to appear using something like t.expect(element.visible).ok(); which however seems a bit odd (running assertion in the beforeEach statement.

Alex Skorkin
  • 4,264
  • 3
  • 25
  • 47
Marian Bazalik
  • 1,351
  • 1
  • 13
  • 30

1 Answers1

2

TestCafe Roles reload a page and apply previously stored cookies and local storage values or perform the initialization steps if there are no stored values. They do not store or change window properties. However, scripts from your page can produce different results due to different local storage values. I think you can create an issue in the TestCafe repository and provide a sample page that can be used to reproduce this behavior.

You can add t.wait or a ClientFunction that returns a Promise to the end of a Role initialization function to postpone creating local storage snapshots.

Andrey Belym
  • 2,893
  • 8
  • 19