Kate Borowski
Kate Borowski

Reputation: 31

Testcafe introduce entry point for tests after authorization

I have a test suite(fixture) with multiple functional tests for test cafe. They look something like this:

fixture('Test suite')
  .page(login_url)
  .beforeEach(async (t) => {
    await t.maximizeWindow()
    await page.signIn('username', 'pass');
  });

test('Test case 1', async (t) => {
  await t.expect(page.title.textContent).eql('My Page');}
test('Test case 2', async (t) => {
  await do some other stuff}

This obviously wastes a lot of time before each test because we need to log in each time. How do I log in once, set that page as an entry point, and start each test from that page?

Upvotes: 3

Views: 143

Answers (1)

Alex Kamaev
Alex Kamaev

Reputation: 6318

You can use the TestCafe Roles mechanism to log in only once. All further tests will not require additional authentication. Take a look at the following article for details: https://devexpress.github.io/testcafe/documentation/guides/advanced-guides/authentication.html#user-roles

Upvotes: 3

Related Questions