Challenge: fix this each() with beforeAll() bug

In a lot of tests you will end up setting things up in beforeAll() - such as creating real or mock database driven items, instantiating classes or objects.

Then also in your Jest or Vitest tests, you will often use .each(), like:

test.each([item1, item2])('testing some variation is true - %s', item => {
  expect(someFn(item)).toBe(true);
});

However, in this challenge we have combined these two techniques and our test is failing. Can you figure out why?

i
Challenge Mode: This lesson is actually a challenge - you are given a half working test and have to figure out how to get it working correctly.

You can use our courses to learn how to solve this challenge - there are courses on everything from basic Jest/Vitest fundamentals, down to how to test frontend code (using React Testing Library).

Loading full lesson content & code...

Share this lessonTweet (X) it

Invite a teammate to learn with you by sharing this lesson or dropping the link in your team chat.

Ready to try running tests for this lesson?