4

I am new to cypress and Mocha. I am writing test cases to an application which has multiple types of users. I am trying to execute a set of test suites for all these multiple users. Traditionally I am expected to login with a user in one test suite, execute the test cases, logout and re login as other user.

But in my case the login is handled by an API, so the number of calls I can make to the API endpoint are very limited. Is there any way I can login once by a user of type A execute test suites, log out and then re-login with Use of Type B and execute all the test suites?

user3567993
  • 173
  • 1
  • 2
  • 11
  • 1
    You can do that by clubbing your test inside single describe for user A and user B and then in `before` method of describe you can login, See https://mochajs.org/#hooks – Tarun Lalwani Sep 18 '20 at 05:47
  • Would it be possible/desirable to mock the login API so you can test with as many different users as you want? – DylanSp Sep 24 '20 at 18:42

0 Answers0