How to do 'beforeEach' only at Fixture level and not for each test under that fixture

。_饼干妹妹 提交于 2019-12-23 16:26:38

问题


I want to run 'beforeEach' only at the fixture level and not for each test under that fixture

fixture `Fixture A for Use Case1`
   .beforeEach(login)

test('A Test 1', async t => {
      await t 
      ---
    }); 

test('A Test 2', async t => {
      await t 
      ---
    }); 
fixture `Fixture B for Use Case2`
    .beforeEach(login)

test('B Test 1', async t => {
      await t 
      ---
    }); 

test('B Test 2', async t => {
      await t 
      ---
    }); 

test('B Test 3', async t => {
      await t 
      ---
    }); 

What Is Happening

The login function is being run before every test under 'Fixture A' and 'Fixture B'

What I Need

I want 'login' to run once at the start of every 'Fixture' and not for every test under the fixtures.

Is it possible? I couldn't find a way on documentation.


回答1:


This is achievable via User Roles and the 'preserve url' option. TestCafe's documentation explains it here: https://devexpress.github.io/testcafe/documentation/test-api/authentication/user-roles.html#optionspreserveurl



来源:https://stackoverflow.com/questions/56624400/how-to-do-beforeeach-only-at-fixture-level-and-not-for-each-test-under-that-fi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!