Safety of Setting State with Jest

Is it safe to set state within a Jest test case or is there any possibility of a collision if one were to get JavaScript to run tests in parallel somehow?

describe('#search', () => {
  let userA, userB, userB, users
  beforeEach(() => {
    userA = createRandomUser()
    userB = createRandomUser()
    userC = createRandomUser()
    users = [userA, userB, userC]

  test('searching for for X', () => {
    userA.age = 25
    userC.age = 27
    const result = search(users, /*... */)
    expect(result).toEqual([userA, userC])

  // More tests which use the users

Also is there a better way to do this without the wieldy let statement or using function and this everywhere?

0 Comment



Captcha image