1

My tests require a promise to be resolved before they start. I have the following:

  • before() hook with the asynchronous call
  • a test on the same level as the before() hook
  • a group of level 2 tests grouped in a nested describe()

The level1 test is correctly synchronized on the promise in the before() hook. However the describe() group is not. Why not and how to synchronize it?

describe('My tests)=> {

  const thePromise$ = (asynchronous call here)

  before(async () => await thePromise$)

  beforeEach(async () => await thePromise$) //an extra safeguard?

  if('Test Level1', ()=> {
   console.log('Test1')
   //won't start until thePromise$ is resolved, excatly as I want
  })

  describe('Level2 Test group', ()={
    console.log('Level2 test group')
    //starts right away, does not wait for the promise to be resolved
  })
})
Ya.
  • 1,671
  • 4
  • 27
  • 53

1 Answers1

1

While I not find a solution to this specific question, I found a way to get done what I really needed, which prompted the question to begin with: how to generate it() tests out of test data that require an asynchronous call to retrieve.

how to generate it() tests after waiting on an asynchronous response

Ya.
  • 1,671
  • 4
  • 27
  • 53